Jump to content
  • Advertisement
Sign in to follow this  
mike4

heading to position transform angle in C++

This topic is 2344 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

Hi
how to transform a normal heading angle in degrees:


0
|
360


to what I want:

180
| |
0
| |
-180


Something alike:
if angle > 180
...
but I cannot figure it. I need to avoid the gap between 0 to 360 for a smooth 3D sound.
Many thanks
Michael

Share this post


Link to post
Share on other sites
Advertisement
i get values from 0 - 360 but want to have a second value following that: 0 - 180 - 0 - -180

But maybe I should try fmod and omit 0 returns, for my sound listener positions?

Share this post


Link to post
Share on other sites
double convert_0_360_angle_to_m180_180(double angle) {
return angle < 180 ? angle : angle - 360;
}


But now you have a gap at 180. If you were to really explain what your problem is, I am sure we could find a solution (which probably doesn't even involve using angles).

Share this post


Link to post
Share on other sites
That's exactly what I try to avoid. This is the sound source position, hence having a gap, for ex. 0 - 360 disrupts sound. No more nice fading in or out depending on listener position.
I've to use/manipulate a degrees 0-360 for the sound source. I've two sounds, one in front and one behind. the one behind is close to 360 hence not usable resulting in sound disruption.
alSource3f(Sources[2], AL_POSITION, heading/10, lY/10, lZ/10);
heading is the value which changes 0-360 as the sound object rotates.
Many thanks
PS: a gap at 180 might be ok, I'll try that now and report back. Edited by mike4

Share this post


Link to post
Share on other sites
No luck, I've already tried something similar.

I have values camera: y,z,y and heading
and for sound source the same. Both change depending on viewer or source location/heading. Probably
I'm doing something completely wrong?

Share this post


Link to post
Share on other sites
What exactly do you do with those headings? Ultimately, the only things that should matter are the sine and cosine of those angles, and those don't have any discontinuities.

Share this post


Link to post
Share on other sites
Yes, for now I only do alike also for the listener:
alListener3f(AL_POSITION, cH/10,cY/10,(lZ/10)+disX);
cH is the heading degree and disX the distance.

Could you tell me how to use sine/cosine with those values?
Many thanks indeed.

Share this post


Link to post
Share on other sites
Wait, you are dividing the heading by 10? Of course that will have trouble with discontinuities!

But, why are you setting the coordinates of AL_POSITION to some angle? That makes no sense at all. Edited by alvaro

Share this post


Link to post
Share on other sites
I did that a long time ago. As far as I remember, only setting x,y,z is not taking in account the airplane movement, hence I did that ugly handicraft. I'll try tomorrow and
get back.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!