From 68314736ee2b8da184a5e01e88b719b4fd64ab49 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Thu, 20 Feb 2020 18:31:32 +0200 Subject: [PATCH] Rotation angle fully in context of the path leg delta gitlab #81 Change-Id: I4f03b62450af42e5680f9e689e6f2fd699184007 --- .../plant3d/scenegraph/controlpoint/PipeControlPoint.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index 72ef4e68..9e9beb9c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -584,11 +584,16 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { final P3DRootNode root = getRoot(); Vector3d up = root != null ? new Vector3d(root.getUpVector()) : new Vector3d(0.0, 1.0, 0.0); - double a = up.angle(getPathLegEndpointVector()); + final Vector3d legDir = getPathLegEndpointVector(); + double a = up.angle(legDir); if (a < 0.1 || (Math.PI - a) < 0.1) { // Rotate components up.set(up.getY(), up.getZ(), up.getX()); } + + // Project up vector into a normal of the leg direction before applying to 'dir' + MathTools.mad(up, legDir, -legDir.dot(up)/legDir.lengthSquared()); + up.normalize(); return getControlPointOrientationQuat(dir, up, angle); } -- 2.47.1