This topic is now archived and is closed to further replies.

Need Math! Got Point A and B Need....

This topic is 6390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a game with sound and I need to figure out right and left volume for the sound source to the players camera. Ok.. In 3D space I just need 2D cordinates (x,y) of point 1 and 2. I can figure out the distance of the two points. sqr((x1 - x2) ^ 2 + (y1 - y2) ^ 2) = distance between X and Y What I need to do is with point 1 and 2 I have to figure out witch side is closer. What would be the best way??? Get a right and left point next to the players location, then calc. the distance from the R and L points to the sound location and figure out the difference for the sound balance? - Joe

Share this post

Link to post
Share on other sites
In 3D space the distance is sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)...

To get the right volume, calculate the unit vector from the player to the sound source, then calculate the scalar product x of the unit right vector of the player with this player-sound source vector. Then the right volume should be (1 + x)/2 (if 1 is the whole volume), the left volume is 1 - right volume.

Visit our homepage:


Edited by - ga on June 13, 2000 6:09:13 PM

Share this post

Link to post
Share on other sites
Well, you should avoid the sqr function at all times. If you ONLY need to find which one is closer, you simply do this

if (x1*x1+y1*y1) < (x2*x2+y2*y2) then
p1 is closer
p2 is closer
end if

See how easy it was to just avoid the sqr function? Well, I got this from "The good-looking textured light-sourced bouncy fun smart and stretchy page."

Captured Reality.

Share this post

Link to post
Share on other sites