Class Geometry
Provides methods regarding geometry math.
Inheritance
Inherited Members
Namespace: Oasys.Common.Logic
Assembly: Oasys.Common.dll
Syntax
public static class Geometry
Methods
AngleBetween(Vector2, Vector2)
Returns the angle with the vector p2 in degrees;
Declaration
public static float AngleBetween(this Vector2 p1, Vector2 p2)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | p1 | The first point. |
SharpDX.Vector2 | p2 | The second point. |
Returns
Type | Description |
---|---|
System.Single |
CenterOfPolygone(Geometry.Polygon)
Returns a Vector2 at center of the polygone.
Declaration
public static Vector2 CenterOfPolygone(this Geometry.Polygon p)
Parameters
Type | Name | Description |
---|---|---|
Geometry.Polygon | p | The polygon. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
CenterPoint(Vector2[])
Declaration
public static Vector2 CenterPoint(this Vector2[] points)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2[] | points |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
CircleCircleIntersection(Vector2, Vector2, Single, Single)
Returns the two intersection points between two circles.
Declaration
public static Vector2[] CircleCircleIntersection(Vector2 center1, Vector2 center2, float radius1, float radius2)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | center1 | The center1. |
SharpDX.Vector2 | center2 | The center2. |
System.Single | radius1 | The radius1. |
System.Single | radius2 | The radius2. |
Returns
Type | Description |
---|---|
SharpDX.Vector2[] |
ClipPolygons(List<Geometry.Polygon>)
Clips the polygons.
Declaration
public static List<List<IntPoint>> ClipPolygons(List<Geometry.Polygon> polygons)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Geometry.Polygon> | polygons | The polygons. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Collections.Generic.List<IntPoint>> |
Close(Single, Single, Single)
Checks if the two floats are close to each other.
Declaration
public static bool Close(float a, float b, float eps)
Parameters
Type | Name | Description |
---|---|---|
System.Single | a | a. |
System.Single | b | The b. |
System.Single | eps | The epsilon. |
Returns
Type | Description |
---|---|
System.Boolean |
Closest(Vector2, List<Vector2>)
Returns the closest vector from a list.
Declaration
public static Vector2 Closest(this Vector2 v, List<Vector2> vList)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The v. |
System.Collections.Generic.List<SharpDX.Vector2> | vList | The v list. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
CrossProduct(Vector2, Vector2)
Returns the cross product Z value.
Declaration
public static float CrossProduct(this Vector2 self, Vector2 other)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | self | The self. |
SharpDX.Vector2 | other | The other. |
Returns
Type | Description |
---|---|
System.Single |
DegreeToRadian(Double)
Converts degrees to radians.
Declaration
public static float DegreeToRadian(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The angle. |
Returns
Type | Description |
---|---|
System.Single |
Distance(GameObjectBase, GameObjectBase, Boolean)
Calculates the 2D distance to the unit.
Declaration
public static float Distance(this GameObjectBase unit, GameObjectBase anotherUnit, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
GameObjectBase | unit | The unit. |
GameObjectBase | anotherUnit | Another unit. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(GameObjectBase, Vector2, Boolean)
Calculates the 2D distance to the point.
Declaration
public static float Distance(this GameObjectBase unit, Vector2 point, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
GameObjectBase | unit | The unit. |
SharpDX.Vector2 | point | The point. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(GameObjectBase, Vector3, Boolean)
Calculates the 2D distance to the point.
Declaration
public static float Distance(this GameObjectBase unit, Vector3 point, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
GameObjectBase | unit | The unit. |
SharpDX.Vector3 | point | The point. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(GameObjectBase, Boolean)
Calculates the 2D distance to the unit.
Declaration
public static float Distance(GameObjectBase anotherUnit, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
GameObjectBase | anotherUnit | Another unit. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(Vector2, GameObjectBase, Boolean)
Calculates the distance to the unit.
Declaration
public static float Distance(this Vector2 v, GameObjectBase to, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The v. |
GameObjectBase | to | To. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(Vector2, Vector2, Vector2, Boolean, Boolean)
Returns the distance to the line segment.
Declaration
public static float Distance(this Vector2 point, Vector2 segmentStart, Vector2 segmentEnd, bool onlyIfOnSegment = false, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | point | The point. |
SharpDX.Vector2 | segmentStart | The segment start. |
SharpDX.Vector2 | segmentEnd | The segment end. |
System.Boolean | onlyIfOnSegment | if set to |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(Vector2, Vector2, Boolean)
Calculates the distance to the Vector2.
Declaration
public static float Distance(this Vector2 v, Vector2 to, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The v. |
SharpDX.Vector2 | to | To. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(Vector2, Vector3, Boolean)
Calculates the distance to the Vector3.
Declaration
public static float Distance(this Vector2 v, Vector3 to, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The v. |
SharpDX.Vector3 | to | To. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance(Vector3, Vector3, Boolean)
Returns the 2D distance (XY plane) between two vector.
Declaration
public static float Distance(this Vector3 v, Vector3 other, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector3 | v | The v. |
SharpDX.Vector3 | other | The other. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Distance3D(GameObjectBase, GameObjectBase, Boolean)
Calculates the 3D distance to the unit.
Declaration
public static float Distance3D(this GameObjectBase unit, GameObjectBase anotherUnit, bool squared = false)
Parameters
Type | Name | Description |
---|---|---|
GameObjectBase | unit | The unit. |
GameObjectBase | anotherUnit | Another unit. |
System.Boolean | squared | if set to |
Returns
Type | Description |
---|---|
System.Single |
Intersection(Vector2, Vector2, Vector2, Vector2)
Intersects two line segments.
Declaration
public static Geometry.IntersectionResult Intersection(this Vector2 lineSegment1Start, Vector2 lineSegment1End, Vector2 lineSegment2Start, Vector2 lineSegment2End)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | lineSegment1Start | The line segment1 start. |
SharpDX.Vector2 | lineSegment1End | The line segment1 end. |
SharpDX.Vector2 | lineSegment2Start | The line segment2 start. |
SharpDX.Vector2 | lineSegment2End | The line segment2 end. |
Returns
Type | Description |
---|---|
Geometry.IntersectionResult |
JoinPolygons(List<Geometry.Polygon>)
Joins all the polygones in the list in one polygone if they interect.
Declaration
public static List<Geometry.Polygon> JoinPolygons(this List<Geometry.Polygon> sList)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Geometry.Polygon> | sList | The polygon list. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Geometry.Polygon> |
JoinPolygons(List<Geometry.Polygon>, ClipType, PolyType, PolyFillType, PolyFillType)
Joins all the polygones. ClipType: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/ClipType.htm PolyFillType: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/PolyFillType.htm
Declaration
public static List<Geometry.Polygon> JoinPolygons(this List<Geometry.Polygon> sList, ClipType cType, PolyType pType = PolyType.ptClip, PolyFillType pFType1 = PolyFillType.pftNonZero, PolyFillType pFType2 = PolyFillType.pftNonZero)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Geometry.Polygon> | sList | The s list. |
ClipType | cType | Type of the c. |
PolyType | pType | Type of the p. |
PolyFillType | pFType1 | The p f type1. |
PolyFillType | pFType2 | The p f type2. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Geometry.Polygon> |
LineCircleIntersection(Single, Single, Single, Vector2, Vector2, out Vector2, out Vector2)
Declaration
public static int LineCircleIntersection(float cX, float cY, float radius, Vector2 segmentStart, Vector2 segmentEnd, out Vector2 intersection1, out Vector2 intersection2)
Parameters
Type | Name | Description |
---|---|---|
System.Single | cX | |
System.Single | cY | |
System.Single | radius | |
SharpDX.Vector2 | segmentStart | |
SharpDX.Vector2 | segmentEnd | |
SharpDX.Vector2 | intersection1 | |
SharpDX.Vector2 | intersection2 |
Returns
Type | Description |
---|---|
System.Int32 |
LineSegmentCircleIntersection(Single, Single, Single, Vector2, Vector2, out Vector2, out Vector2)
Declaration
public static int LineSegmentCircleIntersection(float cX, float cY, float radius, Vector2 segmentStart, Vector2 segmentEnd, out Vector2 intersection1, out Vector2 intersection2)
Parameters
Type | Name | Description |
---|---|---|
System.Single | cX | |
System.Single | cY | |
System.Single | radius | |
SharpDX.Vector2 | segmentStart | |
SharpDX.Vector2 | segmentEnd | |
SharpDX.Vector2 | intersection1 | |
SharpDX.Vector2 | intersection2 |
Returns
Type | Description |
---|---|
System.Int32 |
MovePolygone(Geometry.Polygon, Vector2)
Moves the polygone to the set position. It dosent rotate the polygone.
Declaration
public static Geometry.Polygon MovePolygone(this Geometry.Polygon polygon, Vector2 moveTo)
Parameters
Type | Name | Description |
---|---|---|
Geometry.Polygon | polygon | The polygon. |
SharpDX.Vector2 | moveTo | The move to. |
Returns
Type | Description |
---|---|
Geometry.Polygon |
PathLength(List<Vector2>)
Returns the total distance of a path.
Declaration
public static float PathLength(this List<Vector2> path)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<SharpDX.Vector2> | path | The path. |
Returns
Type | Description |
---|---|
System.Single |
Perpendicular(Vector2)
Returns the perpendicular vector.
Declaration
public static Vector2 Perpendicular(this Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The v. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
Perpendicular2(Vector2)
Returns the second perpendicular vector.
Declaration
public static Vector2 Perpendicular2(this Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The vector. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
PointInLineSegment(Vector2, Vector2, Vector2)
Declaration
public static bool PointInLineSegment(Vector2 segmentStart, Vector2 segmentEnd, Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | segmentStart | |
SharpDX.Vector2 | segmentEnd | |
SharpDX.Vector2 | point |
Returns
Type | Description |
---|---|
System.Boolean |
Polar(Vector2)
Returns the polar for vector angle (in Degrees).
Declaration
public static float Polar(this Vector2 v1)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v1 | The vector. |
Returns
Type | Description |
---|---|
System.Single |
PositionAfter(List<Vector2>, Int32, Int32, Int32)
Returns the position where the vector will be after t(time) with s(speed) and delay.
Declaration
public static Vector2 PositionAfter(this List<Vector2> self, int t, int s, int delay = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<SharpDX.Vector2> | self | The self. |
System.Int32 | t | The time. |
System.Int32 | s | The speed. |
System.Int32 | delay | The delay. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
ProjectOn(Vector2, Vector2, Vector2)
Returns the projection of the Vector2 on the segment.
Declaration
public static Geometry.ProjectionInfo ProjectOn(this Vector2 point, Vector2 segmentStart, Vector2 segmentEnd)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | point | The point. |
SharpDX.Vector2 | segmentStart | The segment start. |
SharpDX.Vector2 | segmentEnd | The segment end. |
Returns
Type | Description |
---|---|
Geometry.ProjectionInfo |
RadianToDegree(Double)
Converts radians to degrees.
Declaration
public static float RadianToDegree(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The angle. |
Returns
Type | Description |
---|---|
System.Single |
RotateAroundPoint(Vector2, Vector2, Single)
Rotates the vector around the set position. Angle is in radians.
Declaration
public static Vector2 RotateAroundPoint(this Vector2 rotated, Vector2 around, float angle)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | rotated | The rotated. |
SharpDX.Vector2 | around | The around. |
System.Single | angle | The angle. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
Rotated(Vector2, Single)
Rotates the vector a set angle (angle in radians).
Declaration
public static Vector2 Rotated(this Vector2 v, float angle)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The vector. |
System.Single | angle | The angle. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
RotatePolygon(Geometry.Polygon, Vector2, Vector2)
Rotates the polygon around to the set direction.
Declaration
public static Geometry.Polygon RotatePolygon(this Geometry.Polygon polygon, Vector2 around, Vector2 direction)
Parameters
Type | Name | Description |
---|---|---|
Geometry.Polygon | polygon | The polygon. |
SharpDX.Vector2 | around | The around. |
SharpDX.Vector2 | direction | The direction. |
Returns
Type | Description |
---|---|
Geometry.Polygon |
RotatePolygon(Geometry.Polygon, Vector2, Single)
Rotates the polygon around the set position. Angle is in radians.
Declaration
public static Geometry.Polygon RotatePolygon(this Geometry.Polygon polygon, Vector2 around, float angle)
Parameters
Type | Name | Description |
---|---|---|
Geometry.Polygon | polygon | The polygon. |
SharpDX.Vector2 | around | The around. |
System.Single | angle | The angle. |
Returns
Type | Description |
---|---|
Geometry.Polygon |
SegmentCircleIntersectionPriority(Vector2, Vector2, Vector2, Single, Vector2, Single)
Declaration
public static int SegmentCircleIntersectionPriority(Vector2 segmentStart, Vector2 segmentEnd, Vector2 circlePos1, float radius1, Vector2 circlePos2, float radius2)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | segmentStart | |
SharpDX.Vector2 | segmentEnd | |
SharpDX.Vector2 | circlePos1 | |
System.Single | radius1 | |
SharpDX.Vector2 | circlePos2 | |
System.Single | radius2 |
Returns
Type | Description |
---|---|
System.Int32 |
SetHeight(Vector3, Nullable<Single>)
Sets the z.
Declaration
public static Vector3 SetHeight(this Vector3 v, float? value = default(float? ))
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector3 | v | The v. |
System.Nullable<System.Single> | value | The value. |
Returns
Type | Description |
---|---|
SharpDX.Vector3 |
Shorten(Vector2, Vector2, Single)
Shortens the specified vector.
Declaration
public static Vector2 Shorten(this Vector2 v, Vector2 to, float distance)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The vector. |
SharpDX.Vector2 | to | The vector to shorten from. |
System.Single | distance | The distance. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
Shorten(Vector3, Vector3, Single)
Shortens the specified vector.
Declaration
public static Vector3 Shorten(this Vector3 v, Vector3 to, float distance)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector3 | v | The vector. |
SharpDX.Vector3 | to | The vector to shorten from. |
System.Single | distance | The distance. |
Returns
Type | Description |
---|---|
SharpDX.Vector3 |
SwitchYZ(Vector3)
Switches the Y and Z.
Declaration
public static Vector3 SwitchYZ(this Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector3 | v | The vector. |
Returns
Type | Description |
---|---|
SharpDX.Vector3 |
To2D(Vector3)
Converts a Vector3 to Vector2
Declaration
public static Vector2 To2D(this Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector3 | v | The v. |
Returns
Type | Description |
---|---|
SharpDX.Vector2 |
To2D(List<Vector3>)
Converts a 3D path to 2D
Declaration
public static List<Vector2> To2D(this List<Vector3> path)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<SharpDX.Vector3> | path | The path. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<SharpDX.Vector2> |
To3D(Vector2)
Converts the Vector2 to Vector3. (Y = Player.ServerPosition.Y)
Declaration
public static Vector3 To3D(this Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The vector. |
Returns
Type | Description |
---|---|
SharpDX.Vector3 |
To3DWorld(Vector2)
Converts the Vector2 to Vector3. (Z = NavMesh.GetHeightForPosition)
Declaration
public static Vector3 To3DWorld(this Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | v | The vector. |
Returns
Type | Description |
---|---|
SharpDX.Vector3 |
ToPolygon(List<IntPoint>)
Converts a list of IntPoint to a polygon.
Declaration
public static Geometry.Polygon ToPolygon(this List<IntPoint> v)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<IntPoint> | v | The int points. |
Returns
Type | Description |
---|---|
Geometry.Polygon |
ToPolygons(List<List<IntPoint>>)
Converts a list of list points to a polygon.
Declaration
public static List<Geometry.Polygon> ToPolygons(this List<List<IntPoint>> v)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.Collections.Generic.List<IntPoint>> | v | The v. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Geometry.Polygon> |
VectorMovementCollision(Vector2, Vector2, Single, Vector2, Single, Single)
Gets the vectors movement collision.
Declaration
public static object[] VectorMovementCollision(Vector2 startPoint1, Vector2 endPoint1, float v1, Vector2 startPoint2, float v2, float delay = 0F)
Parameters
Type | Name | Description |
---|---|---|
SharpDX.Vector2 | startPoint1 | The start point1. |
SharpDX.Vector2 | endPoint1 | The end point1. |
System.Single | v1 | The v1. |
SharpDX.Vector2 | startPoint2 | The start point2. |
System.Single | v2 | The v2. |
System.Single | delay | The delay. |
Returns
Type | Description |
---|---|
System.Object[] |