1
$\begingroup$

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); v.normalizeLocal();  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
    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).2010-12-07

1 Answers 1

1

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.

  • 0
    @CyanPrime: I suspect that the combination of the code and the overall description of what you're trying to do should be enough to figure out an answer, but between other work and lack of familiarity with the programming constructs involved (I know nothing about programming for 3d graphics, etc.), I can't seem to get my head around it at the moment. If you haven't already, I'd suggest posting your code and the restatement of your question from that last comment on StackOverflow (or perhaps gamedev.stackexchange.com, but I don't know anything about that site).2010-12-08