Stumped...
Blitz3D Forums/Blitz3D Programming/Stumped...
| ||
I tried for quite awhile to get this right but it appears the exact algorithm is eluding me. I need to be able to move a moon around a planet with xrot and yrot in the following format. dist# = 300 xrot# = xrot + 1 yrot# = yrot + 1 PositionEntity moon,0+sin(xrot)*dist,0+sin(yrot)*dist,0+cos(xrot+yrot)*dist Orbit around the center (xrot) is fine but the yrot orbit swings the moon away from the planet. Any help is appreciated. **I know I could just put a pivot and do turnentity but I need it to function in this exact manner with sin and cos. |
| ||
You could use a simple pivot to save you calculating the rotations. Pivot = createpivot( PLANET ) Dist# = 300 xrot# = xrot + 1 yrot# = yrot + 1 rotateentity Pivot, xrot, 0, yrot tformpoint 0,0,Dist, Pivot, 0 positionentity Moon, tformedx(), tformedy(), tformedz() [EDIT] Oops, mybad, no idea why you don't want to use a pivot ... seems you want to everything the hard way for some reason. Stevie |
| ||
seems you want to everything the hard way for some reason I don't consider sin and cos hard...but atm I just can't get the right formula. :( |
| ||
Maybe try this formula, it is for a sphere: x#=cos(ang1)*cos(ang2) z#=cos(ang1)*sin(ang2) y#=sin(ang1) |
| ||
Thanks bram and Stevie. I finally got it to work with slight modifications to the above formulas. Another 10 min and I was putting in Stevies code to save my sanity. btw for gee whiz info...the final solution was: PositionEntity orbit_piv,0+(Sin(xrot2)*Cos(yrot2))*dist,0+Sin(yrot2)*dist,0+(Cos(-xrot2)*Cos(-yrot2))*dist |