Struct FinitePlane
Represents a quadrilateral plane defined by four corner points in local space. Used to define finite airfoil geometry with corner points a, b, c, d arranged clockwise or counter-clockwise.
Namespace: NWH.Aerodynamics.Airfoils
Assembly: NWH.Aerodynamics.dll
Syntax
[Serializable]
public struct FinitePlane
Remarks
Corner points are stored as Vector3 but typically represent 2D coordinates in the XZ plane (y=0). The plane can be used for aerodynamic surface calculations and visualization.
Constructors
| Edit this page View SourceFinitePlane(AirfoilTransform, Vector3, Vector3, Vector3, Vector3)
Creates a new FinitePlane with the specified corner points.
Declaration
public FinitePlane(AirfoilTransform t, Vector3 a, Vector3 b, Vector3 c, Vector3 d)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | t | AirfoilTransform reference (not used in constructor). |
| Vector3 | a | First corner point. |
| Vector3 | b | Second corner point. |
| Vector3 | c | Third corner point. |
| Vector3 | d | Fourth corner point. |
Fields
| Edit this page View Sourcea
First corner point in local coordinates.
Declaration
[SerializeField]
public Vector3 a
Field Value
| Type | Description |
|---|---|
| Vector3 |
b
Second corner point in local coordinates.
Declaration
[SerializeField]
public Vector3 b
Field Value
| Type | Description |
|---|---|
| Vector3 |
c
Third corner point in local coordinates.
Declaration
[SerializeField]
public Vector3 c
Field Value
| Type | Description |
|---|---|
| Vector3 |
d
Fourth corner point in local coordinates.
Declaration
[SerializeField]
public Vector3 d
Field Value
| Type | Description |
|---|---|
| Vector3 |
Properties
| Edit this page View SourceArea
Gets the total area of the quadrilateral in square meters. Calculated by dividing the quadrilateral into two triangles.
Declaration
public float Area { get; }
Property Value
| Type | Description |
|---|---|
| float |
center
Gets the geometric center point of the quadrilateral in local space.
Declaration
public Vector3 center { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Methods
| Edit this page View SourceA(AirfoilTransform)
Gets corner point 'a' transformed to world space.
Declaration
public Vector3 A(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Corner point 'a' in world coordinates. |
B(AirfoilTransform)
Gets corner point 'b' transformed to world space.
Declaration
public Vector3 B(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Corner point 'b' in world coordinates. |
C(AirfoilTransform)
Gets corner point 'c' transformed to world space.
Declaration
public Vector3 C(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Corner point 'c' in world coordinates. |
Center(AirfoilTransform)
Gets the geometric center point of the quadrilateral in world space.
Declaration
public Vector3 Center(AirfoilTransform t)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | t | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Center point in world coordinates. |
D(AirfoilTransform)
Gets corner point 'd' transformed to world space.
Declaration
public Vector3 D(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Corner point 'd' in world coordinates. |
DrawGizmos(AirfoilTransform, Color, bool)
Declaration
public void DrawGizmos(AirfoilTransform aT, Color lineColor, bool drawLabels = true)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | aT | |
| Color | lineColor | |
| bool | drawLabels |
FindArea(Vector3, Vector3, Vector3, Vector3)
Calculates the total area of a quadrilateral by dividing it into two triangles.
Declaration
public static float FindArea(Vector3 A, Vector3 B, Vector3 C, Vector3 D)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | A | First corner point. |
| Vector3 | B | Second corner point. |
| Vector3 | C | Third corner point. |
| Vector3 | D | Fourth corner point. |
Returns
| Type | Description |
|---|---|
| float | Total area in square meters. |
FindBestFittingPlane(out Vector3, out Vector3, ref Vector3[])
Finds the best-fitting plane for a set of points using Principal Component Analysis.
Declaration
public static void FindBestFittingPlane(out Vector3 planeCenter, out Vector3 planeNormal, ref Vector3[] points)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | planeCenter | Output center point of the fitted plane in local coordinates. |
| Vector3 | planeNormal | Output normal vector of the fitted plane in local coordinates. |
| Vector3[] | points | Array of points to fit the plane to. |
FindCenter(Vector3, Vector3, Vector3, Vector3)
Finds the geometric center of a quadrilateral. Handles degenerate triangles when point a equals point d.
Declaration
public static Vector3 FindCenter(Vector3 a, Vector3 b, Vector3 c, Vector3 d)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | First corner point. |
| Vector3 | b | Second corner point. |
| Vector3 | c | Third corner point. |
| Vector3 | d | Fourth corner point. |
Returns
| Type | Description |
|---|---|
| Vector3 | Center point as average of all distinct corner points. |
Forward(AirfoilTransform)
Gets the forward direction of the plane in world space.
Declaration
public Vector3 Forward(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for direction conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Forward direction vector in world coordinates. |
GetWidthAlongRight(AirfoilTransform)
Calculates the width of the plane along its right direction.
Declaration
public float GetWidthAlongRight(AirfoilTransform t)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | t | AirfoilTransform to use for coordinate conversion. |
Returns
| Type | Description |
|---|---|
| float | Width in meters along the right axis. |
Normal(AirfoilTransform)
Gets the normal direction of the plane in world space.
Declaration
public Vector3 Normal(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for direction conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Normal direction vector in world coordinates. |
Right(AirfoilTransform)
Gets the right direction of the plane in world space.
Declaration
public Vector3 Right(AirfoilTransform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for direction conversion. |
Returns
| Type | Description |
|---|---|
| Vector3 | Right direction vector in world coordinates. |
SetA(AirfoilTransform, Vector3)
Sets corner point 'a' from a world space position. The y component is zeroed to maintain the point on the XZ plane.
Declaration
public void SetA(AirfoilTransform transform, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
| Vector3 | value | World space position to set. |
SetB(AirfoilTransform, Vector3)
Sets corner point 'b' from a world space position. The y component is zeroed to maintain the point on the XZ plane.
Declaration
public void SetB(AirfoilTransform transform, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
| Vector3 | value | World space position to set. |
SetC(AirfoilTransform, Vector3)
Sets corner point 'c' from a world space position. The y component is zeroed to maintain the point on the XZ plane.
Declaration
public void SetC(AirfoilTransform transform, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
| Vector3 | value | World space position to set. |
SetD(AirfoilTransform, Vector3)
Sets corner point 'd' from a world space position. The y component is zeroed to maintain the point on the XZ plane.
Declaration
public void SetD(AirfoilTransform transform, Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | transform | AirfoilTransform to use for coordinate conversion. |
| Vector3 | value | World space position to set. |
SetToUnitPlane(AirfoilTransform)
Sets the plane to a unit square centered at the origin with 1x1 dimensions. Corner points are arranged on the XZ plane from -0.5 to 0.5 on each axis.
Declaration
public void SetToUnitPlane(AirfoilTransform t)
Parameters
| Type | Name | Description |
|---|---|---|
| AirfoilTransform | t | AirfoilTransform reference (not used). |
TriArea(Vector3, Vector3, Vector3)
Calculates the area of a triangle from its three corner points using the cross product method.
Declaration
public static float TriArea(Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | p1 | First vertex of the triangle. |
| Vector3 | p2 | Second vertex of the triangle. |
| Vector3 | p3 | Third vertex of the triangle. |
Returns
| Type | Description |
|---|---|
| float | Triangle area in square meters. |
ValidateA(float)
Validates and clamps corner point 'a' to ensure it maintains valid geometry relative to adjacent corners. Ensures minimum separation from points b and d to prevent degenerate shapes.
Declaration
public void ValidateA(float margin = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| float | margin | Minimum distance in meters to maintain from adjacent corners. Default 0.01m. |
ValidateABCD(float)
Validates and clamps all four corner points to ensure valid quadrilateral geometry. Calls individual validation methods for each corner in sequence.
Declaration
public void ValidateABCD(float margin = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| float | margin | Minimum distance in meters to maintain between adjacent corners. Default 0.01m. |
ValidateB(float)
Validates and clamps corner point 'b' to ensure it maintains valid geometry relative to adjacent corners. Ensures minimum separation from points a and c to prevent degenerate shapes.
Declaration
public void ValidateB(float margin = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| float | margin | Minimum distance in meters to maintain from adjacent corners. Default 0.01m. |
ValidateC(float)
Validates and clamps corner point 'c' to ensure it maintains valid geometry relative to adjacent corners. Ensures minimum separation from points b and d to prevent degenerate shapes.
Declaration
public void ValidateC(float margin = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| float | margin | Minimum distance in meters to maintain from adjacent corners. Default 0.01m. |
ValidateD(float)
Validates and clamps corner point 'd' to ensure it maintains valid geometry relative to adjacent corners. Ensures minimum separation from points a and c to prevent degenerate shapes.
Declaration
public void ValidateD(float margin = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| float | margin | Minimum distance in meters to maintain from adjacent corners. Default 0.01m. |