]> Shamusworld >> Repos - architektonas/commitdiff
Fixed Line rendering to keep attache Dimensions correct length w/o 'Fix Len'
authorShamus Hammons <jlhamm@acm.org>
Thu, 28 Apr 2011 01:18:45 +0000 (01:18 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 28 Apr 2011 01:18:45 +0000 (01:18 +0000)
src/line.cpp

index b7a11fb2cb300fa0c2c6cddd8220f712cb0ccedc..c2831fcf91368c3b56b8d46fbe86f4dfefc0a29a 100644 (file)
@@ -79,7 +79,7 @@ Line::~Line()
        double parameterizedPoint = lineSegment.Dot(v1) / lineSegment.Magnitude(), distance;
 
        // Geometric interpretation:
-       // pp is the paremeterized point on the vector ls where the perpendicular intersects ls.
+       // The paremeterized point on the vector ls is where the perpendicular intersects ls.
        // If pp < 0, then the perpendicular lies beyond the 1st endpoint. If pp > length of ls,
        // then the perpendicular lies beyond the 2nd endpoint.
 
@@ -217,6 +217,10 @@ Like so:
                Vector v = current.Unit() * length;
                Vector v2 = point1 + v;
 
+               //bleh
+               if (!Object::fixedLength)
+                       v2 = point2;
+
                if (dimPoint1)
                        dimPoint1->SetPoint1(draggingHandle1 ? v2 : position);
                
@@ -232,7 +236,6 @@ Like so:
                // Set the length (in case the global state was set to fixed (or not))
                if (Object::fixedLength)
                {
-
                        if (draggingHandle1)    // startpoint
                        {
                                Vector v = Vector(position - endpoint).Unit() * length;
@@ -351,12 +354,35 @@ n3 ( -by3 , bx3 );
 
 Dot products:
 
-dp1 = n3.v2 = -by3*bx2 + bx3*by2;
-dp2 = n1.v2 = -by1*bx2 + bx1*by2;
+dp1 = n3 . v2 = -by3 * bx2 + bx3 * by2;
+dp2 = n1 . v2 = -by1 * bx2 + bx1 * by2;
 
-ratio = dp1/dp2;
-crossing vector = v1*rat;
+ratio = dp1 / dp2;
+crossing vector = v1 * rat;
 
 And that's it.
+
+-----------------------------------
+
+So... to code this, let's say we have two Lines: l1 & l2.
+
+Vector v1 = l1.endpoint - l1.position;
+Vector v2 = l2.endpoint - l2.position;
+Vector v3 = v2 - v1;
+
+Vector normal1(-v1.y, v1.x);
+Vector normal3(-v3.y, v3.x);
+
+double dotProduct1 = v2.Dot(normal1);
+double dotProduct2 = v2.Dot(normal3);
+
+if (dotProduct2 == 0)
+       return ParallelLines;
+else
+{
+       // I think we'd still have to add the intersection to the position point to get the intersection...
+       Point intersection = v1 * (dotProduct1 / dotProduct2);
+       return intersection;
+}
 */