Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 Re: Help Me ! » Move around circle » 2006-08-10 06:06:53

Thanks Ben, I didn't think of using sin and cos. But I think this is what I need although I would like to stay away from it or use a look up table (for programming speed).

Ricky, perhaps you now understand what I mean with steps? What I like to do is move a camera around a point in a circle in x steps. So at each given step I need to find the new camera position.

#27 Help Me ! » Move around circle » 2006-08-10 03:04:00

safra
Replies: 8

Hi,

I have been looking for circle formula's but cannot find what I need. What I need is a formula that returns the x,y position of a point on a circle with a given center point and diameter or radius based on a start point on the circle and a number of steps. For example if steps is set at 10. And you check the position at step 5, it should return the point opposite of the starting point. Someone knows if this can be put in a formula?

Thanks,
raoul

#28 Re: Help Me ! » get coordinates of point C from A and B » 2006-02-20 22:15:14

Thanks Ricky, the cos sin and arctan functions were/are a bit of a concern as yes they are supposed to be slow. I put it on the list of optimization issues and will test what the fastest solution is (including my silly pythagoras solution wink, but who knows, 10 lines of code can be faster then one line!). Would be nice to know what your findings are, if you wish to share?

Thanks a lot both of you!

#29 Re: Help Me ! » get coordinates of point C from A and B » 2006-02-20 10:39:30

Oh yes, that works great! I now have a ball cam in a direct x game. What I do is use the new and old ball position to get the direction of the ball flight and place the camera either in front or behind the ball at a fixed distance at exactly the height of the ball. Yes, Math is Fun!

Got one weird behavior though, as soon as the ball hits the ground the cam is reversed and actually point A (the new point) gets in between the old point (B) and C (the cam). Quite strange, let's see if I can figure out why that happens.

Thanks a lot John!

#30 Help Me ! » get coordinates of point C from A and B » 2006-02-20 09:40:10

safra
Replies: 8

I have to 2 points A and B with known x and y values. Point C is on the same vector as A and B (the line that crosses A and B). The distance between A and C is constant (for example 50). C can be between A and B or B can be between A and C. A can never be between B and C! What is the fastest way to get the coordinates of C? Hope this makes sense to someone!?

I started with this using pythagoras from the old days back at school and I think I will get there at the end but as this is part of a program I think I will need at least 10 lines with if statements and defining imaginary coordinates when using pythagoras while it should be as fast as possible.

Hope someone can help me with this, thanks!

#31 Re: Help Me ! » line triangle intersection point » 2006-02-14 00:46:19

I started this thread a while ago and thought I found the answer, I guess not as it doesn't work.

Anyone knows a fast way to test if a vertical line intersects the triangle formed by 3 points and if so, find the intersection point?

Thanks,
Raoul

#32 Re: Help Me ! » line triangle intersection point » 2006-01-27 22:00:10

Sorry, This is a line / triangle intersection in a 3D world (directx). Actually what I need to find out is the y position of a landscape at a given position for x and z. so I can place an object on the landscape. A landscape is simply a huge number of vertices. 3 vertices connected to eachother (triangle) form a face. So my thought was, if I make a vertical line with known x and z values and a low and high y value I should be able to find the y value of the landscape at intersection point.

I found this piece of code: http://www.angelfire.com/fl/houseofbartlett/solutions/line2tri.html#Code

But actually this is a bit more complex. I only have access to vertice positions. If I first search for the 3 vertices of which the x and z values are closest to the x and z values of the line and if I then check whether the line is inside the triangle formed by these 3 vertices, will it be certain that these 3 triangles do actualy form a face? I think not. I guess I will have to experiment with this and see how accurate it is in bumpy areas of the landscape.

#33 Help Me ! » line triangle intersection point » 2006-01-27 12:05:46

safra
Replies: 3

Hello!

I found out how to check if a line intersects with a triangle but actually it turns out that, in the case of "yes", I also need the intersection point.

Does someone have a quick way to find this vertice?

Thanks,
Raoul

#34 Re: Help Me ! » more vectors, angles and vertices... » 2005-12-08 07:52:37

Yes, it seems to be fine.

Well at least safra's program is working correctly now.

Still a long way to go though, but taking things step by step wink

#35 Re: Help Me ! » more vectors, angles and vertices... » 2005-12-07 02:49:43

Thanks Irspow. Yes, I did the if statement as I couldn't think of a way to solve this in the function. I am not sure about your second problem with the slope. With that simple if statement of x1 and x2 it seems to work fine. I tried all sorts of possible situations and it does give the desired result. Or, maybe I didn't check on y1 = y2, will do that later when I am back home.

#36 Re: Help Me ! » more vectors, angles and vertices... » 2005-12-05 21:18:10

Works great!

Although I had to deal with two issues (this is a directx 3d project) when the x value of B is higher then x of A then the point is flipped to the wrong side of B. When both x's are the same it also choses the wrong side by default.

#37 Re: Help Me ! » more vectors, angles and vertices... » 2005-12-05 08:48:57

Thanks both!

I will play with this and see if I can translate this to delphi pascal code. One thought (maybe I am misunderstanding your words), the 90 degree angle is at point B (AB and BC) not at point A (AB and AC). Anyway if this means your formula should look a bit different then I should be able to change this myself. I did think of the fact that I didn't mention to which side the 90 degree angle point, thanks for letting me know how to deal with that John.

Raoul

#38 Help Me ! » more vectors, angles and vertices... » 2005-12-04 21:27:01

safra
Replies: 11

Hi again,

I got a new problem based on this thread:

http://www.mathsisfun.com/forum/viewtopic.php?id=2094

Imagine for example a triangle with points A (20,19) and B(15,5) and point C(?,?). The angle at point B is 90 degrees and the distance between B and C is 5. What would be the fastest way to calculate point C?

#39 Re: Help Me ! » calculate position c based on position a and b » 2005-12-04 04:00:49

Thanks Ricky, I think I got it to work.

I did a test, am I right that C will always be a point between A and B in your formula? I need C to be a point 'behind' B with B being on the vector between A and C. I came up with this, which seems to be ok:

Cx = bx + -1*(D*(ax - bx) / L)
Cy = by + -1*(D*(ay - by) / L)

#40 Re: Help Me ! » calculate position c based on position a and b » 2005-12-04 01:34:02

Thanks a lot for responding so quick and great forum (it took me about 5 secs of googling to find it)!

Actually this is a directx 3d issue. I have 2 objects (a and b) on the scene and I would like to place the cam (object C, which will render the visible part of the 3d world) behind object b in the direction of object A. The cam is always positioned on a predefined distance of object B. So you know the positions of object A and B. In directx you work with 3 coordinates but this issue doesn't include the y (vertical) plane only horizontal and depth.

For example the coordinates of A are 50 (x) and 70 (z) and the coordinates of B are 10 (x) and 80 (z), the distance between B and C should be 5. What are the exact x and z coordinates of object C?

Actually, it would also be nice if you would have the formula for all 3 planes.

Thanks!

#41 Help Me ! » calculate position c based on position a and b » 2005-12-03 23:00:12

safra
Replies: 5

Hi there,

My maths are a bit rusty.

I have 2 objects A and B in a 2 dimensional world. I need to calculate the x and y position of object C. C is positioned on the line between A and B and I know that for example the distance between B and C is 5. How can I get the position of B. I know I have to do something with the angles and cosinus or sinus. But I really complete forgot about this.

Hope anyone can help me with this, thanks.

Board footer

Powered by FluxBB