@name Rotate to Angle
@inputs PYR:vector
@outputs Ang:angle Pitch Roll Local:angle Ang1:angle AngDist:angle
@persist 
@trigger 
Self=entity():isConstrainedTo()
if(!Self){Self=entity()}
#runOnTick(1)
P=PYR:x()
Y=PYR:y()
R=PYR:z()
if(abs(R)==180){R=0}
Time=1500/1000
interval(Time*1000)
InertiaConstant = 27.05307927383

Ang=Self:angles()

TargetAng=angnorm(ang(P,Y,R))
Local=Self:toLocal(Self:angles())
Ang1=angnorm(Ang)

AngDist=TargetAng-Local
AngDist=TargetAng-Self:angles()
#    AttackPosition=owner():aimPos() #aim here
#
#    AttackPosition=vec((cos(P)+sin(P)+90),sin(Y)*Rad,sin(R)*Rad)+Self:pos()
#    RelativePosition = Self:toLocal(AttackPosition-(Self:massCenter()-Self:pos()))
#    AngDist = angnorm(RelativePosition:toAngle():setRoll( -Self:angles():roll()))
Inertia = InertiaConstant*ang(Self:inertia():y(),Self:inertia():z(),Self:inertia():x())
AngVel = AngDist/Time
Self:applyAngForce(Inertia*(AngVel-Self:angVel()))

   #This is move to vector code 
#runOnTick(1)
#E=entity()
#T=0.015
#XYZ=owner():aimPos()
#Dist=XYZ-E:pos()
#Vel=Dist/T
#E:applyForce(E:mass()*(Vel-E:vel()))

