Browse
Code
for
All Platforms
in
All Categories
sorted by
Popular
• More ...
• More ...
• More ...
• More ...
• More ...
• More ...
• More ...
• More ...
• More ...
• More ...

# MathUtilities

Released 7 years ago , Last update 7 years ago

A small math-class which can convert degrees to radials and vice versa. It also can calculate the distance between two objects.

To convert degrees to radials, do it like this:

``trace("45degrees = " + MathUtilities.degreesToRadius(45) + "rad");``

To convert radials to degrees, do it like this:

``trace("1rad = " + MathUtilities.radiusToDegrees(1) + "degrees");``

Here's an example of how to create moving circles and calculate the distance between them with this package (view demo to see how it works):

``````package{
import math.Circle;
import math.MathUtilities;

import com.greensock.TweenLite;
import com.greensock.TweenMax;

import flash.display.Sprite;

public class Main extends Sprite{

private var circle1:Circle;
private var circle2:Circle;

public function Main(){
drawCircles();
}

public function drawCircles():void{
circle1 = new Circle( 50, 0xff0000 );
circle2 = new Circle( 10, 0x00ffff );

circle1.x = 0;
circle2.x = stage.stageWidth;

circle1.y = circle2.y = 100;

TweenLite.to( circle1, 5, {x:stage.stageWidth, onUpdate:checkDistance} );
TweenLite.to( circle2, 5, {x:0, onUpdate:checkDistance} );

}

public function checkDistance():void{
var distance:Number = MathUtilities.checkDistance( circle1, circle2);
var hitzone:Number = (circle1.width + circle2.width) /2;

if( (distance - hitzone) <=0  ){
trace("HIT");
TweenMax.killAll();
}

trace(distance - hitzone);
}
}
}``````

## Pricing

### 14 day 14-day money-back guarantee

##### FREE

• 1 site, unlimited servers

• No distribution (hosted use only)

• Commercial use

## Get A Quote

What do you need?
• Custom development
• Integration
• Customization / Reskinning
• Consultation
When do you need it?
• Soon
• Next week
• Next month
• Anytime

### Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

Or enter your name and Email
No comments have been posted yet.