WhoCanDo Posted March 16, 2016 Share Posted March 16, 2016 (edited) Hi, I always have problems understanding vectors so a little help would be appreciated. If I draw a round wall, I would like to find the vector point on the center-line of half the arc length. I can find the radius "Distance (P2.x, P2.y, P3.x, P3.y)" and the angle "SweepAng/2" but how do I get the new vector P4 .. PROCEDURE Main; VAR h : HANDLE; StartAng, SweepAng, ArcRadius : REAL; P1, P2, P3, P4 : VECTOR; BEGIN h := FSObject (ActLayer); GetSegPt1 (h, P1.x, P1.y); hCenter (h, P2.x, P2.y); GetSegPt2 (h, P3.x, P3.y); GetArc (h, StartAng, SweepAng); ArcRadius := Distance (P2.x, P2.y, P3.x, P3.y); Message (StartAng, ' ', SweepAng, ' ', ArcRadius); P4 := Ang2Vec (SweepAng/2, Distance (P2.x, P2.y, P3.x, P3.y)); DSelectAll; h := PickObject (P4.x, P4.y); END; RUN (Main); Edited March 16, 2016 by WhoCanDo Quote Link to comment

WhoCanDo Posted March 16, 2016 Author Share Posted March 16, 2016 Thanks to all that viewed my question. The answer is.. P4.x := P2.x + ArcRadius * Cos (Deg2Rad (SweepAng/2)); P4.y := P2.y + ArcRadius * Sin (Deg2Rad (SweepAng/2)); Quote Link to comment

MullinRJ Posted March 17, 2016 Share Posted March 17, 2016 Halloo, Mr. Do, Late to the party am I, but I want to proffer some alternate algebra to your question. You almost had your answer in your first post. See the following code to see what was missing. And though your trigonometry is spot on, there are some handy vector functions built into VectorScript that make life a little easier once you get familiar with how they work. Again, see following code. To use this script, draw an arc on a design layer, leave it selected and run the script. The script will deselect the arc and place a locus on the arc's mid point. All the best, Raymond (vector junkie) PROCEDURE Main; { St. Patrick's Day 2016 - Raymond Mullin } VAR h : HANDLE; StartAng, SweepAng, ArcRadius, MidAng : REAL; P1, P2 : VECTOR; { ARC Start and Stop points respectively } Pcen, Pmid : VECTOR; { ARC Center and Mid points } Vchord : VECTOR; { line between arc endpoints } BEGIN h := FSActLayer; if (h <> nil) do begin { Get arc data } GetSegPt1 (h, P1.x, P1.y); { start point } GetSegPt2 (h, P2.x, P2.y); { stop point } hCenter (h, Pcen.x, Pcen.y); { center point } GetArc (h, StartAng, SweepAng); { These all yield the same radius value, the } { distance between the arc center and a point on the arc } { Norm() always returns a positive value. } ArcRadius := Distance (Pcen.x, Pcen.y, P1.x, P1.y); ArcRadius := Distance (Pcen.x, Pcen.y, P2.x, P2.y); ArcRadius := Norm(P1-Pcen); ArcRadius := Norm(Pcen-P1); ArcRadius := Norm(P2-Pcen); ArcRadius := Norm(Pcen-P2); { Your 1st expression was almost correct } { you needed the mid angle, not just 1/2 the sweep and } { the new vector needed to be added to the arc's center point } Pmid := Pcen + Ang2Vec (StartAng+SweepAng/2, Distance (Pcen.x, Pcen.y, P1.x, P1.y)); { Another way to express it using vector functions } MidAng := StartAng + SweepAng/2; Pmid := Pcen + Ang2Vec (MidAng, ArcRadius); { Another way using only vector functions. } Vchord := P2 - P1; ArcRadius := Norm(P1-Pcen); Pmid := Pcen + UnitVec(Perp(Vchord)) * ArcRadius; { mark the center point of the arc } DSelectAll; Locus(Pmid.x, Pmid.y); end; { if } END; RUN (Main); Quote Link to comment

WhoCanDo Posted March 18, 2016 Author Share Posted March 18, 2016 Thanks Raymond, Something in you code is ReverseWallSides(h); but when I minimize it, it works fine. Thanks PROCEDURE Main; { St. Patrick's Day 2016 - Raymond Mullin } VAR h : HANDLE; StartAng, SweepAng, ArcRadius : REAL; P1, P2 : VECTOR; { ARC Start and Stop points respectively } Pcen, Pmid : VECTOR; { ARC Center and Mid points } BEGIN h := FSActLayer; if (h <> nil) then BEGIN { Get arc data } GetSegPt1 (h, P1.x, P1.y); { start point } GetSegPt2 (h, P2.x, P2.y); { stop point } hCenter (h, Pcen.x, Pcen.y); { center point } GetArc (h, StartAng, SweepAng); ArcRadius := Distance (Pcen.x, Pcen.y, P1.x, P1.y); Pmid := Pcen + Ang2Vec (StartAng+SweepAng/2, Distance (Pcen.x, Pcen.y, P1.x, P1.y)); DSelectAll; Locus(Pmid.x, Pmid.y); END; { if } END; RUN (Main); Quote Link to comment

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.