From: Reino Ruusu Date: Thu, 20 Feb 2020 16:31:32 +0000 (+0200) Subject: Rotation angle fully in context of the path leg delta X-Git-Tag: v1.43.0~66 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F3895%2F1;p=simantics%2F3d.git Rotation angle fully in context of the path leg delta gitlab #81 Change-Id: I4f03b62450af42e5680f9e689e6f2fd699184007 --- 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); }