[ Home ]

Library Documentation (v 0.13.0)

Geom

Some useful helper geometry functions.
Geom.inbox(x, y, rectx, recty, rectwidth, rectheight):Bool
Returns true if the point (x, y) is in the rectangle (rectx, recty)x(rectwidth, rectheight).
Geom.overlap(x1, y1, w1, h1, x2, y2, w2, h2):Bool
Returns true if the rectangle (x1, y1)x(w1, h1) overlaps with the rectangle (x2, y2)x(w2, h2).
Geom.distance(x1, y1, x2, y2):Float
Returns the distance between the points (x1, y1) and (x2, y2).
Geom.getangle(x1, y1, x2, y2):Float
Returns the angle (in degrees) between the points (x1, y1) and (x2, y2).
Geom.anglebetween(angle1, angle2):Float
Returns the smallest difference between two angles, so that if you add the result to angle1, you get angle2. (All haxegon Geom functions use degrees.)
Geom.clamp(value, min, max):Float
Clamps a value between a min and max. If the value is less than min, return min, if it's more than max, return max, otherwise just return the value.
Geom.todegrees(radians):Float
Converts degrees to radians. (All haxegon Geom functions use degrees.)
Geom.toradians(degrees):Float
Converts radians to degrees. (All haxegon Geom functions use degrees.)
Geom.PI:Float
Is approximately equal to 3.141592653589793.
Geom.abs(value):Float
Returns the absolute value of a number - if it's negative, return the positive of it - otherwise, don't change it. (Same as Math.abs().)
Geom.acos(value):Float
Returns the trigonometric arc cosine of the specified value in degrees. (Almost the same as Math.acos(), except that it returns degrees instead of radians.)
Geom.asin(value):Float
Returns the trigonometric arc sine of the specified value in degrees. (Almost the same as Math.asin(), except that it returns degrees instead of radians.)
Geom.atan(value):Float
Returns the trigonometric arc tangent of the specified value in degrees. (Almost the same as Math.atan(), except that it returns degrees instead of radians.)
Geom.atan2(y:Float, x:Float):Float
Returns the trigonometric arc tangent whose tangent is the quotient of the two specified numbers, in degrees. (Almost the same as Math.atan2(), except that it returns degrees instead of radians.)
Geom.ceil(v:Float):Float
Returns the closest integer that is greater than v - e.g. Geom.ceil(2.7) is 3, Geom.ceil(0.99) is 1. (Same as Math.ceil())
Geom.cos(v:Float):Float
Returns the trigonometric cosine of the specified angle `v`, in degrees. (Almost the same as Math.cos(), except that it returns degrees instead of radians.)
Geom.exp(v:Float):Float
Returns Euler's number, raised to the power of `v`. Geom.exp(1.0) is approximately 2.718281828459. (Same as Math.exp().)
Geom.floor(v:Float):Float
Returns the closest integer that is less than v - e.g. Geom.floor(2.3) is 2, Geom.floor(0.99) is 0. (Same as Math.floor())
Geom.fround(v:Float):Float
Rounds `v` to the nearest integer value, as a Float. Ties are rounded up, so that `0.5` becomes `1` and `-0.5` becomes `0`. (Same as Math.fround())
Geom.log(v:Float):Float
Returns the natural logarithm of `v`. This is the mathematical inverse operation of exp, i.e. log(exp(v)) == v always holds. (Same as Math.log())
Geom.max(a:Float, b:Float):Float
Returns the greater of values `a` and `b`. (Same as Math.max())
Geom.min(a:Float, b:Float):Float
Returns the lesser of values `a` and `b`. (Same as Math.min())
Geom.pow(v:Float, exp:Float):Float
Returns `v` raised to the power `exp`. E.g. Geom.pow(2, 3) is 8. (Same as Math.pow())
Geom.round(v:Float):Float
Rounds `v` to the nearest integer value. Ties are rounded up, so that `0.5` becomes `1` and `-0.5` becomes `0`. (Same as Math.round())
Geom.sin(v:Float):Float
Returns the trigonometric sine of the specified angle `v`, in degrees. (Almost the same as Math.sin(), except that it returns degrees instead of radians.)
Geom.sqrt(v:Float):Float
Returns the square root of `v`. (Same as Math.sqrt())
Geom.tan(v:Float):Float
Returns the trigonometric tangent of the specified angle `v`, in degrees. (Almost the same as Math.tan(), except that it returns degrees instead of radians.)