   mulitple rotating planes
  Hiactually I rotate the airplane in x alike:fx = pX + ((fx - pX) * cos(heading)) - ((pY - fy) * sin(heading))pX is the pilotshead and heading the degrees. fx is the new x and fy is 0.seems ok also with circling camera. a bit sluggish but ok.Now how should i add another source position slightly down in z axis without messing it up? ( front and back of the plane )Many thanksMichael   
  You probably want to switch over to matrices. Dealing with this kind of stuff using explicit trigonometrics is cumbersome. After that step, matrix compositions of translations and rotations can be used to yield in the desired result (although I don't understand what "source position" exactly mean here).   ;  source position = position of sounds in openGL. Im using openAL and want different sound in front and behind the engine/props. I don't think it can be done with matrices in c++. I need smooth transitions in 3D given a degrees angle(heading)[Edited by - mike4linux on May 27, 2010 7:09:42 AM];Quote:I don't think it can be done with matrices in c++.Yes it can. I don't fully understand the problem you're trying to solve, but I can assure you that whatever it is, it can almost certainly be solved using standard tools and techniques (e.g. matrices, quaternions, manipulation of transforms, etc.).If, for example, you're wanting to find the world-space positions of one or more positions on the airplane that are defined in local space, simply multiply the local-space positions by the world/model transform matrix for the airplane.   ;Quote:Original post by mike4linuxI don't think it can be done with matrices in c++.Please notice that the formula shown in the OP can easily be re-written using matricesfx' = pX + [ cos(h) sin(h) ] * ( [ fx fy ]t - [ pX pY ]t )and when fy is considered, too, it looks like (using column vectors)f' = p + R * ( f - p )what further can be re-written, using homogeneous co-ordinates like so:f' = P * R * P-1 * fThis has the typical structure of a rotation around a relocated center.So even if you don't want to use it that way in your application, it is probably a good way to discuss the problem as well as finding a solution.   ;  I'm lost...whatever I try it gets messed up. Those are the most simple formulas i found:------//X Axis Rotation://New Y Coord = Old Y Coord x cos(Ø) - Old Z Coord x sin(Ø)//New Z Coord = Old Y Coord x sin(Ø) + Old Z Coord x cos(Ø)////Y Axis Rotation://New X Coord = Old X Coord x cos(Ø) + Old Z Coord x sin(Ø)//New Z Coord = Old X Coord x -sin(Ø) + Old Z Coord x cos(Ø)////Z Axis Rotation//New X Coord = Old X Coord x cos(Ø) - Old Y Coord x sin(Ø)//New Y Coord = Old X Coord x sin(Ø) + Old Y Coord x cos(Ø)and those are the data I have:http://www.xsquawkbox.net/xpsdk/docs/DataRefs.htmlsearch for: /pos to get to: sim/flightmodel/position/I tried using psi (heading) & pilotshead position. Weird...this shouldn't bethat complicated.Many thanks for any helpMichael;  The formulas above show standard rotations (as can simply be expressed using matrices ;)). However, be aware that you've used the same symbol for 3 different angles.When choosing the object space axes as rotation axes, then the particular rotations are named yaw, pitch, and roll (or bank). Heading is often used as a synonyme for yaw, but technically that isn't correct: Heading is around the inertial space upright axis, while yaw is around the object space upright axis. Only in the case that yaw is the first rotation done (as is the case for the standard yaw-pitch-roll order), then the axes of heading and yaw are coincident and can be used alternatively. However, there are always 3 consecutive rotations with an individual angle for each axis.I think the problem for us is that we still don't understand your intention. The most probable possibility of what you desire is IMHO an Euler rotation with a re-located center. So decide which Euler rotation order is suitable for your needs, compose an overall rotation, e.g. (if using column vectors)R := Ryaw * Rpitch * Rrollwith the 3 angles, and wrap that with the desired center transformation like so:P * R * P-1BTW: The ∅ isn't a psi (which looks like Ψ); it has most similarity with a (upper case) phi Φ, but denotes in fact an empty set ∅.   ;  Thanks but I don't understand your formula. Using only C++ and the data given what would a simple way look like?Camera is working so not to bother about that. Then using the airplane data from the datarefs to place two sound positions on the plane's z? axis. Front and back of the plane. Thanks againMichael;Quote:Original post by mike4linuxThanks but I don't understand your formula. Using only C++ and the data given what would a simple way look like?The 1st formula concatenates the 3 particular rotations, each one given as a matrix, in the order yaw then pitch then roll (using column vectors) into a composite matrix. The 2nd formula is best explained when you look back into my 2nd post in this thread.There is no sense in writing down "only C++" because (a) AFAIK you're not using a matrix math library, and (b) I'm not inclined to write down such a formula in scalars, because it would cost me too much time and would be very likely subject to bugs. Really, oblige yourself and learn matrices and vectors. For example, look at Euclidean Space Site for some enlightenment.It would really be helpful if you'd explain in detail what you're trying to solve! For example, a description should answer such questions like:* You have given the location and orientation of a plane, relative to the world, with which parameters? Euler angles, perhaps?* You have given the location of the pilot' head. It is given relative to what reference? The plane? Should or should not the head be used as the "ear" for hearing the sounds?* You have given the orientation of the pilot's head. Is it free, or is it always aligned like the plane?* You have the position of 2 sound sources, each one relative to the plane's reference frame?* You want to compute the positions of the 2 sources relative to the pilot's head? Or what?;  Thanks but the link looks much more complicated then my formulas above.* You have given the location and orientation of a plane, relative to the world, with which parameters? Euler angles, perhaps?Yes if you look at the link i gave above you see that I have several coordinates. Actually I use localview - cameraview = listener position-----------//getting the values:camX = XPLMFindDataRef("sim/graphics/view/view_x");camY = XPLMFindDataRef("sim/graphics/view/view_y");camZ = XPLMFindDataRef("sim/graphics/view/view_z");locX = XPLMFindDataRef("sim/flightmodel/position/local_x");locY = XPLMFindDataRef("sim/flightmodel/position/local_y");locZ = XPLMFindDataRef("sim/flightmodel/position/local_z");psi = XPLMFindDataRef("sim/flightmodel/position/psi");viewT = XPLMFindDataRef("sim/graphics/view/view_is_external");pilotX = XPLMFindDataRef("sim/graphics/view/pilots_head_x");pilotY = XPLMFindDataRef("sim/graphics/view/pilots_head_y");pilotZ = XPLMFindDataRef("sim/graphics/view/pilots_head_z");later:heading = psi * 3.14 / 180.0;again later trying this or pilots_head:fy = locY * cos(heading) - locZ * sin(heading);fz = locY * sin(heading) + locZ * cos(heading);// giving the positions to openal:SourcesPos[1][0] = 0.0;SourcesPos[1][1] = fy;SourcesPos[1][2] = fz;----------Still need to set the sound source positions on the plane. I tried this with the pilotshead position but either this is wrong or my formulas. I wouldn't know how to use the local coordinates of the plane as for the viewer/listener position. Also using the psi degrees for the heading. * You have given the location of the pilot' head. It is given relative to what reference? The plane? Should or should not the head be used as the "ear" for hearing the sounds?Pilots positions are simply something like x=2, y=3, z=1.4 or so. And they don't change at all, so i believe they are relative to the plane? * You have given the orientation of the pilot's head. Is it free, or is it always aligned like the plane?I don't want to use this but psi or phi for the heading.* You have the position of 2 sound sources, each one relative to the plane's reference frame?Yes i can place them where i want. So i tried to place them one a little in front of the pilot and one to the back. Later I'd try to put them to the side as well. (openAL sounds positions)* You want to compute the positions of the 2 sources relative to the pilot's head? Or what?I tried this as using local plane coordinates are very high numbers and therefore not very exact but this might be one of my faults. Maybe using local plane coordinates minus something would be more accurate together with the plane's heading.Many thanks for your helpMichael