Math Question

  • Thread starter Thread starter Superfluous_Nut
  • Start date Start date
S

Superfluous_Nut

Guest
Okay, lessee if mathmajor is worth his salt...

I'm interested in finding the smallest value of 't' where two moving line segments intersect. (t being time)

the two lines connect are (x1(t),y1(t))-(x2(t),y2(t)) and (a1(t),b1(t))-(a2(t),b2(t))

x1(t) = x1.previous * (1-t) + x1.current * t
y1(t) = y1.previous * (1-t) + y1.current * t
x2(t) = ...
etc


da(t) = a2(t)-a1(t)
db(t) = b2(t)-b1(t)
dx(t) = x2(t)-x1(t)
dy(t) = y2(t)-y1(t)


u = (da(t)*(b1(t)-y1(t)) - db(t)*(a1(t)-x1(t)))
. ------------------------------------------
. dy(t)*da(t) - db(t)*dx(t)

u = intersection point along (x1,y1)-(x2,y2) line. u<0 means it's off the segment, as does u>1.

Anybody have any suggestions?
 
Originally posted by Superfluous_Nut
Anybody have any suggestions?

Yeah. Don't rely on message board people to help you solve your math problems.
 
Originally posted by Superfluous_Nut
Yeah, okay, just thought I'd ask...

I don't remember any of that stuff. I'd love to get back into it for kicks, but I'm literally just a math major - not a working mathematician.

Now if you want me to troubleshoot something for you....
 
u gonna let us know the answer, right nut?

man, i wont be able to sleep if you dont... (JESSKIDDING)

u asking bec u want to know the answer, or do you already know the answer and just wants to know who else does?

:D
 
I have no clue what the answer is. I'd like to know for a game I'm writing...
 
I do a little math now and then....I might could help.

Let me see if I understand this correctly. So there are two line segments, in the x-y plane, defined by these expressions of time t. I assume this means that t is discrete and starts at 0 (t=0,1,2,3,...). The two end points of each line segment are defined recursively by the formulas you put up there.

But I'm a little confused by the recursion - when you have

x1(t) = x1.previous * (1-t) + x1.current * t

is this the same as

x1.current = x1.previous * (1-t) + x1.current * t

? I'm not sure. Maybe an example would help illustrate it? Also, what kind of initial values do you have for x1, x2, etc.?

Anyhow, I think that your problem can be solved without too much trouble. Actually I find it kind of interesting. :cool:
 

Members online

Latest posts

Trending content

Forum statistics

Threads
158,350
Posts
2,824,302
Members
10,558
Latest member
garyfrank231
Back
Top