|
|
Jan Walzer wrote in message <3a66275e@news.povray.org>...
>the post where someone had a fancy ball flying around and some kind of
>"guns" followed him ...
>
>I know it was here a VERY long time ago, and I don't know from whom it was,
>but he must have used a macro that takes an location and a target as
vectors
>and gives back some rotations ...
I wrote a couple of macros to do that:
#macro Bearing(__Location, __Target)
degrees(atan2((__Location.z-__Target.z),-(__Location.x-__Target.x)))
#end
#macro Elevation(__Location, __Target)
degrees(atan2((__Target.y-__Location.y),sqrt(sqr(__Location.x-__Target.x)+sq
r(__Location.z-__Target.z))))
#end
Bearing() gives you the rotation around the y axis for the gun turret, and
Elevation() gives you the rotation about the z axis for the gun. Example:
Your gun turret is at <1,2,3>, and you are shooting at a target at <-5,4,7>:
union{
object{GunBarrel rotate z*Elevation(<1,2,3>,<-5,4,7>)}
object{GunTurret}
rotate y*Bearing(<1,2,3>,<-5,4,7>)
translate <1,2,3>
}
--
Mark
Post a reply to this message
|
|