Need help finding T

JHawkNH

New member
Joined
Jun 25, 2009
Messages
6
Here is the equation:

X= P[sub:ekr13a1q]0[/sub:ekr13a1q](1-T)[sup:ekr13a1q]2[/sup:ekr13a1q] + 2TP[sub:ekr13a1q]1[/sub:ekr13a1q](1-T) + T[sup:ekr13a1q]2[/sup:ekr13a1q]P[sub:ekr13a1q]2[/sub:ekr13a1q]

I need to sovle this for T.
X, P[sub:ekr13a1q]0[/sub:ekr13a1q], P[sub:ekr13a1q]1[/sub:ekr13a1q], P[sub:ekr13a1q]2[/sub:ekr13a1q] are all given values so T is the only unknown.

Some of you might recognize this as a 3 Point Bezier Curve. I need this for a program I am writting. It has been many years since I tried to solve a complex problem like this so my skills are unfortunetly very rusty.

Any help would be greatly apprisiated.
 
Do the math to rearrange as a quadratic (I'm using a,b,c for your P0,P1,P2) :

(a + c - 2b)T^2 + (2b - 2a)T + a - x = 0

Since you're working with such equations, I'm sure you've heard of the quadratic formula :shock:
 
\(\displaystyle T=\frac{-\left(\sqrt{(P_{0}-2P_{1}+P_{2})x-P_{0}\cdot P_{2}+P_{1}^{2}}-P_{0}+P_{1}\right)}{P_{0}-2P_{1}+P_{2}}\)

or

\(\displaystyle T=\frac{\sqrt{(P_{0}-2P_{1}+P_{2})x-P_{0}\cdot P_{2}+P_{1}^{2}}+P_{0}-P_{1}}{P_{0}-2P_{1}+P_{2}}\)
 
Thank you. Now I can start doing my per pixel calculations in the program.
 
(I'm using a,b,c for your P0,P1,P2) :
(a + c - 2b)T^2 + (2b - 2a)T + a - x = 0

Since you're programming, may be quite easier to do it this way:
U = a + c - 2b
V = 2b - 2a
W = a - x

(makes equation UT^2 + VT + W = 0)

T = [-V + sqrt(V^2 - 4W)] / (2U)
or
T = [-V - sqrt(V^2 - 4W)] / (2U)
 
Denis said:
(I'm using a,b,c for your P0,P1,P2) :
(a + c - 2b)T^2 + (2b - 2a)T + a - x = 0

Since you're programming, may be quite easier to do it this way:
U = a + c - 2b
V = 2b - 2a
W = a - x

(makes equation UT^2 + VT + W = 0)

T = [-V + sqrt(V^2 - 4W)] / (2U)
or
T = [-V - sqrt(V^2 - 4W)] / (2U)

Correct me if I am wrong, but shouldn't it be

T = [-V + sqrt(V^2 - 4UW)] / (2U)
or
T = [-V - sqrt(V^2 - 4UW)] / (2U)
 
YES Hawk, you're correct...my 1st mistake this year :roll:
 
JHawkNH said:
Here is the equation:

X= P[sub:3f1l1lc2]0[/sub:3f1l1lc2](1-T)[sup:3f1l1lc2]2[/sup:3f1l1lc2] + 2TP[sub:3f1l1lc2]1[/sub:3f1l1lc2](1-T) + T[sup:3f1l1lc2]2[/sup:3f1l1lc2]P[sub:3f1l1lc2]2[/sub:3f1l1lc2]

Assuming it is a quadratic in T -

X= P[sub:3f1l1lc2]0[/sub:3f1l1lc2](1-T)[sup:3f1l1lc2]2[/sup:3f1l1lc2] + 2TP[sub:3f1l1lc2]1[/sub:3f1l1lc2](1-T) + T[sup:3f1l1lc2]2[/sup:3f1l1lc2]P[sub:3f1l1lc2]2[/sub:3f1l1lc2]

X= P[sub:3f1l1lc2]0[/sub:3f1l1lc2](1+T[sup:3f1l1lc2]2[/sup:3f1l1lc2] - 2T)+ 2TP[sub:3f1l1lc2]1[/sub:3f1l1lc2](1-T) + T[sup:3f1l1lc2]2[/sup:3f1l1lc2]P[sub:3f1l1lc2]2[/sub:3f1l1lc2]

X= T[sup:3f1l1lc2]2[/sup:3f1l1lc2]{ P[sub:3f1l1lc2]0[/sub:3f1l1lc2] + P[sub:3f1l1lc2]2[/sub:3f1l1lc2] - 2P[sub:3f1l1lc2]1[/sub:3f1l1lc2]} + T{2P[sub:3f1l1lc2]1[/sub:3f1l1lc2]- 2P[sub:3f1l1lc2]0[/sub:3f1l1lc2]} + P[sub:3f1l1lc2]0[/sub:3f1l1lc2]

T[sup:3f1l1lc2]2[/sup:3f1l1lc2]{ P[sub:3f1l1lc2]0[/sub:3f1l1lc2] + P[sub:3f1l1lc2]2[/sub:3f1l1lc2] - 2P[sub:3f1l1lc2]1[/sub:3f1l1lc2]} + T{2P[sub:3f1l1lc2]1[/sub:3f1l1lc2]- 2P[sub:3f1l1lc2]0[/sub:3f1l1lc2]} + {P[sub:3f1l1lc2]0[/sub:3f1l1lc2]-X} = 0

This is a quadratic equation of the form

AT[sup:3f1l1lc2]2[/sup:3f1l1lc2] + BT + C = 0

where

T [sub:3f1l1lc2]1,2[/sub:3f1l1lc2] = [-B ± ?(B[sup:3f1l1lc2]2[/sup:3f1l1lc2] - 4AC)]/[2A]

There you have it......





I need to sovle this for T.
X, P[sub:3f1l1lc2]0[/sub:3f1l1lc2], P[sub:3f1l1lc2]1[/sub:3f1l1lc2], P[sub:3f1l1lc2]2[/sub:3f1l1lc2] are all given values so T is the only unknown.

Some of you might recognize this as a 3 Point Bezier Curve. I need this for a program I am writting. It has been many years since I tried to solve a complex problem like this so my skills are unfortunetly very rusty.

Any help would be greatly apprisiated.
 
Denis said:
YES Hawk, you're correct...my 1st mistake this year :roll:

No problem. It was your first post that got me over the mental block I was having. If it wasn't for that I never would have got this far. :D
 
Denis said:
YES Hawk, you're correct...my 1st mistake this year :roll:

Ha

Ha .. Ha .. Ha

I am running out of fingers here...... :lol: :lol: :lol: :lol: :lol:
 
Top