42 lines
952 B
Haxe
42 lines
952 B
Haxe
package ru.m.geom;
|
|
|
|
abstract Circle(Array<Float>) {
|
|
public var x(get, set):Float;
|
|
public var y(get, set):Float;
|
|
public var radius(get, set):Float;
|
|
|
|
public function new(x:Float = 0, y:Float = 0, radius:Float = 0) {
|
|
this = [
|
|
x, y, radius,
|
|
];
|
|
}
|
|
|
|
private inline function get_x():Float {
|
|
return this[0];
|
|
}
|
|
|
|
private inline function set_x(value:Float):Float {
|
|
return this[0] = value;
|
|
}
|
|
|
|
private inline function get_y():Float {
|
|
return this[1];
|
|
}
|
|
|
|
private inline function set_y(value:Float):Float {
|
|
return this[1] = value;
|
|
}
|
|
|
|
private inline function get_radius():Float {
|
|
return this[2];
|
|
}
|
|
|
|
private inline function set_radius(value:Float):Float {
|
|
return this[2] = value;
|
|
}
|
|
|
|
public function contain(point:Point):Bool {
|
|
return Math.sqrt(Math.pow(point.x - x, 2) + Math.pow(point.y - y, 2)) < radius;
|
|
}
|
|
}
|