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

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

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 by hippothamus

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;

Thanks Guys,

Yes Miguel, the technical explanation was exactly what I needed.

Regards

## 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.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×

• KBASE
• #### MARIONETTE

×
• Create New...