Jump to content
  • Advertisement
Sign in to follow this  

line equation

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello all, stuck with simple math:: i've a known 3D vector & it originates from a known 3D point; how do i find a point on the vector at some distance d .charley

Share this post

Link to post
Share on other sites
Make the vector a unit vector then multiply by d. This gives you a vector of length d starting at the known point and in the direction of the original known vector.

Share this post

Link to post
Share on other sites
thanks for your reply; once i get the vector of distance d starting from a known point in the same direction of the old vector,

how can i find the end point or the intermediate pts....

vector (x,y,z) = pt2. - pt1. (x,y,z)

and hence assuming pt1. be the known origin pt. of vector, pt2 is nothing but vx - pt1x, vy - pt1y, vz - pt1z where vx, vy, vz are the coefficients of vector.

for intermediate points, i've to use the parametric equation of the line

x1 = x0 + vx.t;......

Is that correct ?


Share this post

Link to post
Share on other sites
Well, I'm confused by your new questions. In general, you have the right idea in that you have to take the starting known point into account to find the end point. And I think your first equation is right (if I understood correctly). Basically, the endpoint of the new vector (what you called pt2 I think) is the sum of the starting point (pt1) and the new vector (you called vector). So
pt2 = pt1 + vector;
But, then your equation for intermediate points looks like it includes time (t?). Are you trying to compute the position as a function of time?

Maybe this will help:
Given a point (x1,y1,z1) and a vector from that point (vx1,vy1,vz1), then you can find a new point (x2,y2,z2) at any distance d along that vector by the following:
% Make vector1 a unit vector
vmag = sqrt(vx1^2+vy1^2+vz1^2);
unit_vector_x = vx1/vmag;
unit_vector_y = vy1/vmag;
unit_vector_z = vz1/vmag;
% Then multiply by the desired distance d and include the starting point:
x2 = x1 + d*vx1/vmag;
y2 = y1 + d*vy1/vmag;
z2 = z1 + d*vz1/vmag;

So these equations can work for the endpoint and any intermediate points. If you want to move the point over time, then you just have to vary d over time. If d changes from 0 to some dmax, then the new point (x2,y2,z2) will move along the original vector from the start point to whatever dmax is.

Hope that's what you are looking for. I have to leave any minute now, but will try to check back tomorrow if noone else has answered further.

P.S. I hope this isn't a homework question, collegguy.
EDITs: just fiddling around with source and code tags - I guess it looks just as good with nothing - so left it alone.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!