• Create Account

### #Actualreppinfreedom

Posted 17 November 2012 - 11:52 PM

Okay... So I created a function to convert a x/y velocity into an angle...

Now, I need to solve for the velocity... It something as simple as Math.sqrt(xVel + yVel)?<br />
[source lang=&amp;amp;quot;java&amp;amp;quot;]<br />public static function xyVelToAngle(xyVel:Point):Number {<br />   var Angle:Number = Math.atan2(xyVel.y,xyVel.x);<br />   var Degrees:Number = 360 * (Angle / (2 * Math.PI));<br />   if (Degrees &amp;amp;lt; 0) {<br />    Degrees = Degrees + 360;<br />   }<br />   return Degrees;<br />  }<br />[/source]

### #3reppinfreedom

Posted 17 November 2012 - 11:47 PM

Okay... So I created a function to convert a x/y velocity into an angle...

Now, I need to solve for the velocity... It something as simple as Math.sqrt(xVel + yVel)?<br />
[source lang=&amp;quot;java&amp;quot;]<br />public static function xyVelToAngle(xyVel:Point):Number {<br />   var Angle:Number = Math.atan2(xyVel.y,xyVel.x);<br />   var Degrees:Number = 360 * (Angle / (2 * Math.PI));<br />   if (Degrees &amp;lt; 0) {<br />    Degrees = Degrees + 360;<br />   }<br />   return Degrees;<br />  }<br />[/source]

Ok... Final function... Hopefully this is correct!!!

[source lang=&amp;quot;java&amp;quot;] public static function xyVelToVelAngle(xyVel:Point):Object {
var velAngle:Object = new Object();
var Angle:Number = Math.atan2(xyVel.y,xyVel.x);
var Degrees:Number = 360 * (Angle / (2 * Math.PI));
if (Degrees < 0) {
Degrees = Degrees + 360;
}
velAngle.Angle = Degrees;
velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y);
return velAngle;
}</pre>

### #2reppinfreedom

Posted 17 November 2012 - 11:41 PM

<p>Okay... So I created a function to convert a x/y velocity into an angle...<br />
<br />
Now, I need to solve for the velocity... It something as simple as Math.sqrt(xVel + yVel)?<br />
[source lang=&quot;java&quot;]<br />public static function xyVelToAngle(xyVel:Point):Number {<br />   var Angle:Number = Math.atan2(xyVel.y,xyVel.x);<br />   var Degrees:Number = 360 * (Angle / (2 * Math.PI));<br />   if (Degrees &lt; 0) {<br />    Degrees = Degrees + 360;<br />   }<br />   return Degrees;<br />  }<br />[/source]</p>
<p> </p>
<p>Ok... Final function... Hopefully this is correct!!!</p>
<p> </p>
<pre>
[source lang=&quot;java&quot;] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees &lt; 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x + xyVel.y); return velAngle; }[/source]</pre>

### #1reppinfreedom

Posted 17 November 2012 - 11:38 PM

Okay... So I created a function to convert a x/y velocity into an angle...

Now, I need to solve for the velocity... It something as simple as Math.sqrt(xVel + yVel)?
[source lang="java"]public static function xyVelToAngle(xyVel:Point):Number { var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } return Degrees; }[/source]

PARTNERS