heading to position transform angle in C++

Started by
29 comments, last by rip-off 11 years, 11 months ago
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
Advertisement
Can you explain what you are trying to do?
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?
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).
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.
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?
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.
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.
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.
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.

This topic is closed to new replies.

Advertisement