Table of Contents

Class PairZrUtil

Namespace
Hi.Geom
Assembly
HiGeom.dll

Utility class for working with PairZr objects

public static class PairZrUtil
Inheritance
PairZrUtil
Inherited Members

Methods

GetIntensiveZrs(IEnumerable<PairZr>, double)

public static IEnumerable<PairZr> GetIntensiveZrs(this IEnumerable<PairZr> src, double ZResolution)

Parameters

src IEnumerable<PairZr>
ZResolution double

Returns

IEnumerable<PairZr>

GetMaxRByZ(IReadOnlyList<PairZr>, double)

Gets the largest R of a profile at a specified Z position: every segment between two consecutive points that spans z contributes its interpolated R, and a vertical step at z (two consecutive points with the same Z) contributes the larger of its two radii. The points need not be sorted; null elements are skipped. Where GetRByZ(List<PairZr>, double) answers one side of a step, depending on which point its search lands on, this is the outer surface a plane at z cuts.

public static double GetMaxRByZ(this IReadOnlyList<PairZr> zrs, double z)

Parameters

zrs IReadOnlyList<PairZr>

The profile points; consecutive non-null points form the segments

z double

The Z position

Returns

double

The largest R over the segments spanning z; NaN when no segment spans it (fewer than two points, z outside the profile, or z NaN)

GetRByZ(List<PairZr>, double)

Gets the R value at a specified Z position by interpolating between PairZr objects in a list

public static double GetRByZ(this List<PairZr> zVsPairZr, double z)

Parameters

zVsPairZr List<PairZr>

The list of PairZr objects

z double

The Z position to get the R value for

Returns

double

The interpolated R value at the specified Z position, or NaN if interpolation is not possible

GetRByZ(SortedList<double, PairZr>, double)

Gets the R value at a specified Z position by interpolating between PairZr objects in a sorted list

public static double GetRByZ(this SortedList<double, PairZr> zVsPairZr, double z)

Parameters

zVsPairZr SortedList<double, PairZr>

The sorted list of PairZr objects keyed by Z values

z double

The Z position to get the R value for

Returns

double

The interpolated R value at the specified Z position, or NaN if interpolation is not possible

GetRadialEnvelope(IEnumerable<tri3d_t>, int)

The outline tris sweeps turning about the Z axis, as Z-R points from the lowest height to the highest: at each height a vertex is at, the farthest the plane at that height cuts the mesh from the axis – the triangles crossing it as much as the ones with a corner on it – taken just below the height, at it and just above it, so a step, a flange or a groove is drawn level at its height (two points at one Z, in the order the surface runs upward) and a bore or a thread inside the body draws nothing; consecutive repeats dropped, so a vertex height gives one to three points. Between two vertex heights the outline is the straight line, which is exact on a cylinder or a cone and never inside the surface elsewhere. A mesh whose vertices sit at more than maxHeightNum heights – a tilted mesh puts nearly every vertex at a height of its own – is read at that many even heights from its lowest to its highest instead, drawn to that resolution: an even height between vertex heights gives one point, or none where the mesh has a gap there; one that falls on a vertex height gives one to three; and a step or a groove between two even heights is bridged by the straight line between them.

public static List<PairZr> GetRadialEnvelope(this IEnumerable<tri3d_t> tris, int maxHeightNum)

Parameters

tris IEnumerable<tri3d_t>

The mesh; a triangle with a vertex that is not finite is left out.

maxHeightNum int

The most heights the envelope is read at, 2 or more; MaxValue reads every vertex height (GetZrList(IEnumerable<tri3d_t>)).

Returns

List<PairZr>

The envelope, heights ascending; empty when no triangle is finite.

Exceptions

ArgumentNullException

tris is null.

ArgumentOutOfRangeException

maxHeightNum is below 2.

GetVolume(IGetZrList)

Calculates the volume of an object that implements IGetZrList

public static double GetVolume(this IGetZrList src)

Parameters

src IGetZrList

The object that implements IGetZrList

Returns

double

The calculated volume, or 0 if the source is null

GetVolume(IEnumerable<PairZr>)

Get Volume. Assume the src.Z is ascendent. If Z descendent, the result may be negative.

public static double GetVolume(this IEnumerable<PairZr> src)

Parameters

src IEnumerable<PairZr>

Returns

double

GetZrList(IGetStl)

The Z-R contour of a geometry: its own when it states one (IGetZrList); otherwise the radial envelope of its mesh (GetZrList(IEnumerable<tri3d_t>)), generated at the geometry's default resolution when it generates one (IGenStl) and read from it otherwise. A wrapper that does not state a contour of its own (a transformed geometry) is read from its mesh, however simple the shape inside.

public static List<PairZr> GetZrList(this IGetStl geom)

Parameters

geom IGetStl

The geometry

Returns

List<PairZr>

The contour, heights ascending; null when the geometry or its mesh is null

GetZrList(IEnumerable<tri3d_t>)

The Z-R contour of a mesh: the radial envelope of tris about the Z axis (GetRadialEnvelope(IEnumerable<tri3d_t>, int)), read at every height a vertex of the mesh is at. At each height the plane there cuts the mesh – the triangles crossing it as much as the ones with a corner on it – and the farthest point of the cut from the axis is kept, taken just below the height, at it and just above it, so a step, a flange or a groove reads level at its height (two points at one Z, in the order the surface runs upward) and a bore or a thread inside the body reads nothing. Between two vertex heights the contour is the straight line: exact on a cylinder or a cone, never inside the surface elsewhere.

public static List<PairZr> GetZrList(this IEnumerable<tri3d_t> tris)

Parameters

tris IEnumerable<tri3d_t>

The mesh; a triangle with a vertex that is not finite is left out.

Returns

List<PairZr>

The contour, heights ascending, consecutive repeats dropped; empty when no triangle is finite.

Exceptions

ArgumentNullException

tris is null.

TryGetNormal2d(SortedList<double, PairZr>, double, out vec2d_t)

Tries to get a 2D normal vector to the surface at the specified Z position

public static bool TryGetNormal2d(this SortedList<double, PairZr> zVsPairZr, double z, out vec2d_t normal)

Parameters

zVsPairZr SortedList<double, PairZr>

The sorted list of PairZr objects defining the surface

z double

The Z position to get the normal vector for

normal vec2d_t

The 2D normal vector to the surface, when the method returns true

Returns

bool

True when z lies inside the list's Z range; false when the list is empty, z is NaN, or z is below the first or above the last Z

TryGetNormal2dByFittedZ(SortedList<double, PairZr>, double, out double, out vec2d_t)

Tries to get a 2D normal vector to the surface at the specified Z position, adjusted to fit within the Z range

public static bool TryGetNormal2dByFittedZ(this SortedList<double, PairZr> zVsPairZr, double z, out double fittedZ, out vec2d_t normal)

Parameters

zVsPairZr SortedList<double, PairZr>

The sorted list of PairZr objects defining the surface

z double

The Z position to get the normal vector for

fittedZ double

Output parameter that receives the adjusted Z value that fits within the range; NaN when the list is empty or z is NaN

normal vec2d_t

The 2D normal vector to the surface, when the method returns true

Returns

bool

True when the normal exists; false when the list is empty or z is NaN

TryGetSurfaceVerticalArrow2d(List<PairZr>, double, out vec2d_t)

Tries to get a 2D vector perpendicular to the surface at the specified Z position

public static bool TryGetSurfaceVerticalArrow2d(this List<PairZr> zVsPairZr, double z, out vec2d_t arrow)

Parameters

zVsPairZr List<PairZr>

The list of PairZr objects defining the surface

z double

The Z position to get the vector for

arrow vec2d_t

The 2D vector perpendicular to the surface, when the method returns true

Returns

bool

True when z lies inside the contour's Z range; false when the list is empty, z is NaN, or z is below the first or above the last Z

TryGetSurfaceVerticalArrow2dByFittedZ(List<PairZr>, double, out double, out vec2d_t)

Tries to get a 2D vector perpendicular to the surface at the specified Z position, adjusted to fit within the Z range

public static bool TryGetSurfaceVerticalArrow2dByFittedZ(this List<PairZr> zVsPairZr, double z, out double fittedZ, out vec2d_t arrow)

Parameters

zVsPairZr List<PairZr>

The list of PairZr objects defining the surface

z double

The Z position to get the vector for

fittedZ double

Output parameter that receives the adjusted Z value that fits within the range; NaN when the list is empty or z is NaN

arrow vec2d_t

The 2D vector perpendicular to the surface, when the method returns true

Returns

bool

True when the surface vector exists; false when the list is empty or z is NaN

TryGetSurfaceVerticalArrow3dByFittedZ(List<PairZr>, double, double, out double, out vec3d_t)

Tries to get a 3D vector perpendicular to the surface at the specified Z position, adjusted to fit within the Z range

public static bool TryGetSurfaceVerticalArrow3dByFittedZ(this List<PairZr> zVsPairZr, double z, double angle_rad, out double fittedZ, out vec3d_t arrow)

Parameters

zVsPairZr List<PairZr>

The list of PairZr objects defining the surface

z double

The Z position to get the vector for

angle_rad double

The angle in radians to position the vector around the Z axis

fittedZ double

Output parameter that receives the adjusted Z value that fits within the range; NaN when the list is empty or z is NaN

arrow vec3d_t

The 3D vector perpendicular to the surface, when the method returns true

Returns

bool

True when the surface vector exists; false when the list is empty or z is NaN