Jump to content
Developer Wiki and Function Reference Links ×

How do you shorten a GetLine3D

Recommended Posts

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;


h : handle;

p1X, p1Y, p1Z, p2X, p2Y, p2Z : real;


GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false);

Poly3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z);

h := ConvertToNurbs (LNewObj, false);

Message (LengthN (Sel=True));


run (test);

Link to comment

Just to expand on the vector solution:


vec1,vect2: VECTOR;

p1X,p1Y,p1Z,p2X,p2Y,p2Z,p3X,p3Y,p3Z,dist1,dist2: REAL;




{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;




Link to comment

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...