From: Shamus Hammons Date: Thu, 28 Apr 2011 01:18:45 +0000 (+0000) Subject: Fixed Line rendering to keep attache Dimensions correct length w/o 'Fix Len' X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59a3d6f929427e308efbf5fcfe997be51e2af399;p=architektonas Fixed Line rendering to keep attache Dimensions correct length w/o 'Fix Len' --- diff --git a/src/line.cpp b/src/line.cpp index b7a11fb..c2831fc 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -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; +} */