Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Alright, so I got two points in 3d space, so they have a x,y, and z. Now if the line's y - which I get like so:

Vector3 v = new Vector3();
v = a.subtract(b, v);

float cosine = (float);
float angle = (float) Math.toDegrees(Math.acos( cosine ));

Now I have a third point (the c point), which is inside the line of a and b. now I need to know how to get point a and b to 0 and 1, than I need to find out where c is on the line. my goal is to have something like c.y = b.y - (a.y * c.x and c.z's point on the line (which will be between 0 and 1))

So how do I do this?

share|cite|improve this question
Your first order of business is to construct a parametric equation $\mathbf h(t)=(a+bt\quad c+dt\quad e+ft)$ such that $\mathbf h(0)$ corresponds to one endpoint, and $\mathbf h(1)$ corresponds to the other endpoint. (Hint: direction cosines). – J. M. Dec 7 '10 at 18:26

I'm not entirely sure that this answers what you're asking--if not, please comment so that I can revise it.

If you have two points $A$ and $B$, the set of points $P=(1-t)\cdot A+t\cdot B$, where $t$ is a real number, is the line through $A$ and $B$, parameterized with $A=P|_{t=0}$ and $B=P|_{t=1}$.

If you know for sure that $C$ is on the line through $A$ and $B$, then set $C=(1-t)\cdot A+t\cdot B$ and solve for $t$ in any one of the components (if $C$ is in fact on the line, then the value of $t$ will be the same, regardless of which component you use; if $C$ is not on the line, then the value of $t$ will not be the same for each component).

note: edited to fix equation $P=$ in the second paragraph, and correspondingly in the third paragraph.

share|cite|improve this answer
So the dots are dot products? what are they? also what does P|t=0 mean? – CyanPrime Dec 8 '10 at 0:10
@CyanPrime: The dots are scalar multiplication: $t\cdot(x,y,z)=(tx,ty,tz)$. By $P|_{t=0}$ I meant evaluate $P$ when $t=0$. – Isaac Dec 8 '10 at 0:21
Alright, so c = (t * a.x, t * a.y, t * a.z) + (1-t * b.x, 1-t * b.y, 1-t * b.z) And t can be any number I want? – CyanPrime Dec 8 '10 at 1:11
@CyanPrime: For $0<t<1$, the point will be between $A$ and $B$; for $t<0$ or $t>1$, the point will still be on the line, but not between $A$ and $B$. – Isaac Dec 8 '10 at 1:15
Does having a different number as t change the outcome? If so, what number should I use to make it between 1 and 0? – CyanPrime Dec 8 '10 at 1:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.