WhoCanDo Posted April 14, 2015 Share Posted April 14, 2015 With GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false); I can get the beginning and end point of a 3D line but if I want to calculate the points 5mm shorter at one end or 5mm shorter at the other end then how can I calculate this? procedure test; var h : handle; p1X, p1Y, p1Z, p2X, p2Y, p2Z : real; begin GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false); Poly3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z); h := ConvertToNurbs (LNewObj, false); Message (LengthN (Sel=True)); end; run (test); Quote Link to comment
Hippocode Posted April 14, 2015 Share Posted April 14, 2015 (edited) See the line as a vector. VS has a datatype VECTOR and some appropriate functions to do the following: Assign a vector parameter. Get the unitvector and distance. you can now find any point on that line. Edited April 14, 2015 by hippothamus Quote Link to comment
Miguel Barrera Posted April 14, 2015 Share Posted April 14, 2015 Just to expand on the vector solution: VAR vec1,vect2: VECTOR; p1X,p1Y,p1Z,p2X,p2Y,p2Z,p3X,p3Y,p3Z,dist1,dist2: REAL; BEGIN {.......} {.......} {vector starting at p1 and ending at p2} vec1.x:= p2X - p1X; vec1.y:= p2Y - p1Y; vec1.z:= p2Z - p1Z; dist1:= Norm(vec1); {Length of vec1} dist2:= dist1 - 5; {Assuming mm is the default unit. Otherwise use 5mm} vect2:= dist2 * UnitVec(vec1); {UnitVec is the vector that is 1 unit long} {p3 is 5 units shorter than p2} p3X:= p1X + vect2.x; p3Y:= p1Y + vect2.y; p3Z:= p1Z + vect2.z; {.......} {.......} END; Quote Link to comment
WhoCanDo Posted April 15, 2015 Author Share Posted April 15, 2015 Thanks Guys, Yes Miguel, the technical explanation was exactly what I needed. Regards 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.