I just tought i try to do a documentation for my/other Libs we currently got to help Devs create new Scripts more easier.
2DGeometry is a Lib that provides you with some cool geometrical functions.
There exist 5 different geometrical classes you can use:
POINT
--Takes a 3D Vector or an obj as input and converts it to a 2D Point Point:__init(x, y, z) --[[____EXAMPLE____ local p = Point(myHero.pos) print(p.type) --> Point --]] --Compares 2 points Point:__equal(Object) --[[____EXAMPLE____ local p1, p2 = Point(myHero.pos), Point(mousePos) local bool = p1:__equal(p2) print(bool) --> true/false --]] --Neagtativate a Point Point:__makeNegative() --Add a Point to another or by a value Point:__addition(v) --Returns the addition value of the Point Point:__additionValue() --Perependicular Point:__perpendicular() --Substract a Point Point:__substract(v) --Multiply a Point Point:__multiply(v) --Divide a Point Point:__divide(v) --Get the length of a Point Point:__length() --multiplay a Point by itslef Point:__expand() --Translate a Point to a string value Point:__toString() --Clone a Point Point:__clone() --Returns all Points in Point (its just the Point) Point:__getPoints() --Check if Point is inside of an object Point:__insideOf(Object) --Distance from Point to different objects Point:__distance(Object) --Returns the closest Point to a given Point on a given Segment Point:__ClosestPointTo(Object)
LINE
--Creates a Line between 2 Points Line:__init(Point1, Point2) --Conmpares 2 Lines Line:__equal(Object) --Returns the Points of a Line Line:__getPoints() --Returns the Linesegemnts (Line is a infinite Segment) Line:__getLineSegments() --Check if Line contains an object Line:__contains(Object) --Check if the Line is inside an other object Line:__insideOf(Object) --Returns the distance of the Line to other objects Line:__distance(Object) --Draws the Line Line:__draw(width, color) --[[____EXAMPLE____ local p1, p2 = Point(myHero.pos), Point(mousePos) local l1 = Line(p1, p2) --OnDraw li:__draw() --]]
LINESEGMENT
--Creates a LineSegment
LineSegment:__init(point1, point2)
--Compares 2 LineSegments
LineSegment:__equal(spatialObject)
--Retunrs the Points of a LineSegment
LineSegment:__getPoints()
--Returns the LineSegemnts of a LineSegemnt (self)
LineSegment:__getLineSegments()
--Returns the direction of a LineSegment
LineSegment:__direction()
--Returns the length of a LineSegment
LineSegment:__len()
--Checks if a LineSegment conrains an object
LineSegment:__contains(spatialObject)
--Checks if a LineSegment is inside an object
LineSegment:__insideOf(spatialObject)
--Returns the distance of a LineSegment to an other object
LineSegment:__distance(spatialObject)
--Checks for intersiction between a LineSegment and an object
LineSegment:__intersects(spatialObject, a, b)
--Draws a LineSegment
LineSegment:__draw(width, color)
CIRCLE
--Creates a Cirle
Circle:__init(point, radius)
--Comapres 2 Circles
Circle:__equal(spatialObject)
--Returns the Points of a circle
Circle:__getPoints()
--Returns the LineSegements of a Circle (Circles dont have LineSegemnts)
Circle:__getLineSegments()
--Check if a Circle contains an object
Circle:__contains(spatialObject)
--Check if a Circle is inside an object
Circle:__insideOf(spatialObject)
--Returns the distance from the circle to an other object
Circle:__distance(spatialObject)
--Returns the intersection points of the circle and an object
Circle:__intersectionPoints(spatialObject)
--Translates a Circle to a string
Circle:__toString()
--Draws a Cirlce
Circle:__draw(width, color)
POLYGON
--Creates a Polygon
Polygon:__init(...)
--Comapres 2 Polygons
Polygon:__equal(spatialObject)
--Retunrs the points of a Polygon
Polygon:__getPoints()
--Add a point to a Polygon
Polygon:__addPoint(point)
--Returns the LineSegments of a Polygon
Polygon:__getLineSegments()
--Checks if a Polygon contains an object
Polygon:__contains(spatialObject)
--Checks if a Polygon is inside of an object
Polygon:__insideOf(spatialObject)
--Returns the direction of a Polygon
Polygon:__direction()
--Triangulate a Polygon
Polygon:__triangulate()
--Checks if a Poylgon intersects with an object
Polygon:__intersects(spatialObject)
--Returns the intersection points of an object with a Polygon
Polygon:__intersectionPoints(spatialObject, sort)
--Returns the diatance of an object to a Polygon
Polygon:__distance(spatialObject)
--Translate a Polygon to a string
Polygon:__toString()
--Draws a Polygon
Polygon:__draw(width, color)
(This lib is automatically downloaded but if you want to see the source)
Source (raw)
CREDITS: Husky, Yonderboi, Me, Myself & I