From: Marko Luukkainen Date: Tue, 16 Jul 2019 17:34:13 +0000 (+0300) Subject: Fixed path leg direction vector calculation X-Git-Tag: v1.43.0~248 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F3023%2F1;p=simantics%2F3d.git Fixed path leg direction vector calculation * Calculated direction was opposite to the actual direction gitlab #12 Change-Id: I8ea135f3cec5a0d80e42c9a2d9ecb626fb4f11a5 --- 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 b822b2f3..b8198bda 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 @@ -303,9 +303,11 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public Vector3d getSizeChangeOffsetVector(Vector3d dir) { + Quat4d q; if (rotationAngle == null) - rotationAngle = 0.0; - Quat4d q = getControlPointOrientationQuat(dir, rotationAngle); + q = getControlPointOrientationQuat(dir, 0.0); + else + q = getControlPointOrientationQuat(dir, rotationAngle); Vector3d v = new Vector3d(0.0,offset,0.0); Vector3d offset = new Vector3d(); MathTools.rotate(q, v, offset); @@ -313,9 +315,11 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public Vector3d getSizeChangeOffsetVector() { + Quat4d q; if (rotationAngle == null) - rotationAngle = 0.0; - Quat4d q = getControlPointOrientationQuat(rotationAngle); + q = getControlPointOrientationQuat(0.0); + else + q = getControlPointOrientationQuat(rotationAngle); Vector3d v = new Vector3d(0.0,offset,0.0); Vector3d offset = new Vector3d(); MathTools.rotate(q, v, offset); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index 606479ad..5f52c525 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -345,8 +345,8 @@ public class PipingRules { ErrorLogger.defaultLogError("Updating pipe run, found offset controlpoint " + icp, new Exception("ASSERT!")); } if (offsets.size() == 0) { - dir.set(startPoint); - dir.sub(endPoint); + dir.set(endPoint); + dir.sub(startPoint); double l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l)); @@ -355,8 +355,8 @@ public class PipingRules { } else { Vector3d sp = new Vector3d(startPoint); Point3d ep = new Point3d(endPoint); - dir.set(sp); - dir.sub(ep); + dir.set(ep); + dir.sub(sp); double l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l)); @@ -375,8 +375,8 @@ public class PipingRules { break; } ep = nep; - dir.set(sp); - dir.sub(ep); + dir.set(ep); + dir.sub(sp); l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l));