Class PolygonProximity
Defines a proximity outlined by a 2D polygon.
public class PolygonProximity : IPolygonProximity, INearestPointProximity, IAttachableProximity<IAttachedPolygonProximity>, IProximity, IShapeVolume, ICloneable, IFormattable
- Inheritance
-
PolygonProximity
- Implements
-
IShapeVolume
- Inherited Members
- Extension Methods
Constructors
PolygonProximity(IEnumerable<Vector2>, float?, float?)
Create a polygon with a set of points.
public PolygonProximity(IEnumerable<Vector2> points, float? minHeight, float? maxHeight)
Parameters
pointsIEnumerable<Vector2>A set of points with at least 3 elements.
minHeightfloat?Optional minimum Y value.
maxHeightfloat?Optional maximum Y value.
Exceptions
- ArgumentException
pointshas less than 3 elements or one of the points isn't finite.
Properties
Area
The 2D area of the shape when looking down.
public float Area { get; }
Property Value
MaxHeight
Maximum Y value of the polygon.
public float? MaxHeight { get; }
Property Value
MinHeight
Minimum Y value of the polygon.
public float? MinHeight { get; }
Property Value
Points
Ordered list of all points in the polygon.
public IReadOnlyList<Vector2> Points { get; }
Property Value
- IReadOnlyList<Vector2>
internalVolume
Internal cubic meter volume.
public float internalVolume { get; }
Property Value
surfaceArea
Surface square meters area.
public float surfaceArea { get; }
Property Value
worldBounds
Not necessarily cheap to calculate - probably best to cache.
public Bounds worldBounds { get; }
Property Value
- Bounds
Methods
Clone()
Creates a new object that is a copy of the current instance.
public object Clone()
Returns
- object
A new object that is a copy of this instance.
TestPoint(in Vector2)
Check if a position is within the proximity while ignoring Y position.
public bool TestPoint(in Vector2 position)
Parameters
positionVector2
Returns
TestPoint(in Vector3)
Check if a position is within the proximity.
public bool TestPoint(in Vector3 position)
Parameters
positionVector3
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.