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

You are not logged in. #1 20060221 08:40:10
get coordinates of point C from A and BI 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!? #2 20060221 08:53:13
Re: get coordinates of point C from A and Bslope = (By  Ay) / (Bx  Ax) igloo myrtilles fourmis #3 20060221 09:39:30
Re: get coordinates of point C from A and BOh 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! #4 20060221 09:46:34
Re: get coordinates of point C from A and BNo prob. igloo myrtilles fourmis #5 20060221 12:27:06
Re: get coordinates of point C from A and B
Haven't really check to see if these are the right answers, I'm just going to assume they are. Oh, and if speed of your program doesn't matter, none of the below will... Code:for (x = 0; x < 2*PI; x+=PI/720.0) { o << sin(x) << endl; } Now generate that file for whatever trig functions you are using. Then, in the beginning of your program, you load up these data values into a hash table. From this, you can then approximate each trig function in O(1) time, which means constant time, the fastest you can get. I picked the value PI/720. This will generate a fairly small file (1440 lines). You can use higher values such as PI/1000 or even PI/2000, and you will get a very close approximation. With 2000, that will probably be as close an approximation as just sin(x) is. Last edited by Ricky (20060221 12:28:26) "In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..." #6 20060221 12:40:39
Re: get coordinates of point C from A and BMaking a hash table for arctan will be funny to use, because the slope changes by leaps and bounds between 88 degrees igloo myrtilles fourmis #7 20060221 13:22:30
Re: get coordinates of point C from A and BMaybe you can just ignore that post all together... Last edited by Ricky (20060221 13:23:25) "In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..." #8 20060221 13:55:53
Re: get coordinates of point C from A and BI think the pentium processor might have a floating point processor in it to do trig?? Just a guess. igloo myrtilles fourmis #9 20060221 21:15:14
Re: get coordinates of point C from A and BThanks 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 , 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? 