Math Question!

Started by Ryan Timothy B, Sat 08/08/2009 18:22:23

Previous topic - Next topic

Ryan Timothy B

No worries Bulbapuck.  I still appreciate the help. :P


On a side note, I just used Gilbet's solution to find the stopping speed.  Yay!
0.1 = 3.0/(((46.5/3.0)*2.0)-1.0)

I first needed the solution to find out if the object will be stopping within that 'area'.  Then I needed to increase or decrease the stopping speed to have it stop exactly where I wanted it within the 'area'.

Thanks again guys.

Ryan Timothy B

Sorry, I hate to ask here again but it always takes me ages to find something that I'm looking for with Google for anything that involves math I'm unfamiliar with.

Basically I have 2 lines.  They could go on for infinite, not sure if that information matters or not.  But it's basically just within a square and once it leaves that square it doesn't matter anymore (which is the easy part).

Here's an image:

The black lines are the 2 lines.  I basically need to find out if a point is within these lines (in the red area) or not.

Does anyone know what math solution I should use, a link to a math website explaining this, or even simply just what terms I should be using in my Google search?
Thanks!

Bulbapuck

There are a lot of ways to do this, but I think a simple one would be to assign formulas for the lines (y = kx + m) and check the x-value for the point and then put that x-value into the formulas for the lines. If the y-value for one of the lines you get is larger than the y-value for the point and the other is smaller then it's within the area.

Wyz

#23
assuming you have:
Code: math

y1 = ax + b
y2 = cx + d

ax + b < y < cx + d

or

cx + d < y < ax + b

gives:
((y1 < y) && (y < y2)) || ((y2 < y) && (y < y1))


edit:
That's what Bulba's already said. ;D

uhm... Maybe you're having trouble getting lines in the form y = ax +b. In that case you can calculate the a and b from two points on a line:

Code: math

(u1,v1) and (u2,v2)
y = u2 - u1
v = v2 - v1

a = v / y
b = v1 - (a * u1)
Life is like an adventure without the pixel hunts.

Ryan Timothy B

Oh wow I didn't even think of using a line equation.  Doh.  I was thinking there would be some crazy math formula to solve for it. :P
I'll give it a whirl tonight once I'm done work.  Thanks.

SMF spam blocked by CleanTalk