]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fixed path leg direction vector calculation 23/3023/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 17:34:13 +0000 (20:34 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 17:34:13 +0000 (20:34 +0300)
* Calculated direction was opposite to the actual direction

gitlab #12

Change-Id: I8ea135f3cec5a0d80e42c9a2d9ecb626fb4f11a5

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java

index b822b2f3535ebf0c85f6302e9fb53706e0902234..b8198bda253fc0f57c6864e627f112df1f95780b 100644 (file)
@@ -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);
index 606479ad8e09f1299b607455de37e6b9341a10f7..5f52c52521ac8ad4b56b78be49741547225ea920 100644 (file)
@@ -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));