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) v.dot(v);
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?

  • 2
    $\begingroup$ 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). $\endgroup$ – J. M. ain't a mathematician 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.

  • $\begingroup$ So the dots are dot products? what are they? also what does P|t=0 mean? $\endgroup$ – CyanPrime Dec 8 '10 at 0:10
  • $\begingroup$ @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$. $\endgroup$ – Isaac Dec 8 '10 at 0:21
  • $\begingroup$ 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? $\endgroup$ – CyanPrime Dec 8 '10 at 1:11
  • $\begingroup$ @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$. $\endgroup$ – Isaac Dec 8 '10 at 1:15
  • $\begingroup$ Does having a different number as t change the outcome? If so, what number should I use to make it between 1 and 0? $\endgroup$ – CyanPrime Dec 8 '10 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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