xmsinterp  1.0
xms::AnisotropicInterpolator Class Reference

Class to transform points relative to a centerline polyline into a space where the centerline segments are conceptually rotated to lie on the x-axis. The points used to interpolate from will be projected via a normal onto each centerline segment. The distance along that centerline where that normal intersects will be the new x (or s) value. The new y (or n) value will be the distance of the point above or below the centerline to that intersection. The z value remains unchanged. Note that a point can project onto multiple centerline segments. An option allows from using only the transformation of each point with the smallest n. Points to interpolate "to" will be transformed the same way. Then an inverse distance weighting (raised to a power) from the interpolation points will be used to compute the interpolated z value. This is an internal implementation class used by InterpAnisotropic. More...

#include <AnisotropicInterpolator.h>

Public Member Functions

 AnisotropicInterpolator ()
 Constructor.
 
void SetPoints (const VecPt3d &a_centerlinePts, const VecPt3d &a_interpolationPts, bool a_pickClosest=false)
 Set the centerline points to parameterize to. More...
 
const VecPt3dGetInterpolationPoints () const
 Get the transformed interpolation points in (s, n, z) space. More...
 
double InterpolatePoint (const Pt3d &a_target, const VecPt3d &a_interpolationPoints, double a_xScale, double a_IDWPower=2, double a_tol=1.0e-5)
 Interpolate the z coordinate of the interpolation points to point a_target. More...
 
VecPt3d ComputeInterpolationPoints (const VecPt3d &a_interpolationPts, bool a_pickClosest)
 Transforms a set of points from normal (x, y, z) coordinates to (s, n, z) coordinates. Note: The z coordinate is left unchanged. More...
 
double Distance (const Pt3d &a_p0, const Pt3d &a_p1) const
 Compute the distance between two points. More...
 
double AnisotropicDistanceSquared (const Pt3d &a_p0, const Pt3d &a_p1, double a_xScale)
 Compute the distance squared between two points, after a scale factor is applied to their x coordinates. More...
 
double CalculateIDW (double a_xScale, const VecPt3d &a_points, const Pt3d &a_target, double a_power, double a_tol=1.0e-5)
 Calculates the Inverse Distance Weighted interpolation of a set of points at a target point. More...
 
double CrossProduct (size_t a_segmentIndex, const Pt3d &a_p) const
 Compute the 2d cross product of the vectors from a_p to the 1st and last points in a segment of m_centerLinePts. The cross product will be positive if a_p is to the left of the vector from first to last point in the segment, negative if to the right, and 0.0 if on the line segment. More...
 
LineParameters GetLineParameters (const Pt3d &a_p0, const Pt3d &a_p1) const
 Compute the 2d slope and intercept for a line through two points. More...
 
double GetParameterInSegment (size_t a_segmentIndex, const Pt3d &a_p) const
 Compute the parameter for a point in a segment of m_centerLinePts. The parameter will be between 0 and 1 if the normal to the segment through the point is between the segment end points. It will be < 0 if the point projects onto the segment before the first point and > 1 if it projects onto the line after the second point. More...
 
bool GetIntersectionOfSegmentWithPoint (size_t a_segmentIndex, const Pt3d &a_p, Pt3d &a_intersection, double &a_param) const
 Get the intersecting point and its parameter of a line through point a_p normal to a segment of m_centerLinePts. More...
 
void GetNormalPointParameter (size_t a_segmentIndex, const Pt3d &a_p, double &a_lastParam, VecSNResult &a_results) const
 Append the transform (if any) of a point to a centerline segment. More...
 
void GetAllNormalPointParameters (const Pt3d &a_p, VecSNResult &a_results)
 Get the SNResults for a point. More...
 
VecPt3d TransformPoint (const Pt3d &a_p, bool a_onlyClosest=false)
 Transforms a point from (x, y, z) to (s, n, z) coordinates. s is for station (distance along the centerline) and n for normal (perpendicular distance) to a segment to m_centerLinePts. The z coordinate is left unchanged. More...
 

Public Attributes

VecPt3d m_centerLinePts
 The polyline representing the centerline.
 
VecDbl m_accLengths
 The accumulated distance along the centerline of each point.
 
std::vector< LineParametersm_lineParams
 
VecPt3d m_SNPoints
 The interpolation points.
 

Detailed Description

Class to transform points relative to a centerline polyline into a space where the centerline segments are conceptually rotated to lie on the x-axis. The points used to interpolate from will be projected via a normal onto each centerline segment. The distance along that centerline where that normal intersects will be the new x (or s) value. The new y (or n) value will be the distance of the point above or below the centerline to that intersection. The z value remains unchanged. Note that a point can project onto multiple centerline segments. An option allows from using only the transformation of each point with the smallest n. Points to interpolate "to" will be transformed the same way. Then an inverse distance weighting (raised to a power) from the interpolation points will be used to compute the interpolated z value. This is an internal implementation class used by InterpAnisotropic.

Definition at line 91 of file AnisotropicInterpolator.h.

Member Function Documentation

◆ AnisotropicDistanceSquared()

double xms::AnisotropicInterpolator::AnisotropicDistanceSquared ( const Pt3d a_p0,
const Pt3d a_p1,
double  a_xScale 
)

Compute the distance squared between two points, after a scale factor is applied to their x coordinates.

Parameters
[in]a_p0The first point.
[in]a_p1The second point.
[in]a_xScaleThe scale factor to apply to the x coordinate.
Returns
The anisotropic distance between the points.

Definition at line 222 of file AnisotropicInterpolator.cpp.

References xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by CalculateIDW().

◆ CalculateIDW()

double xms::AnisotropicInterpolator::CalculateIDW ( double  a_xScale,
const VecPt3d a_points,
const Pt3d a_target,
double  a_power,
double  a_tol = 1.0e-5 
)

Calculates the Inverse Distance Weighted interpolation of a set of points at a target point.

Parameters
[in]a_xScaleThe scale factor to apply to the x coordinates when computing anisotropic distance.
[in]a_pointsThe points to interpolate from (presumably in [s, n, z] space).
[in]a_targetThe point in (s,n,?) whose z coordinate is to be interpolated.
[in]a_powerThe exponent to apply to the inverse distance weighting.
[in]a_tolIf the distance squared between a_target and a point in a_points is less than or equal to this tolerance, just return the z coordinate of that point.
Returns
A weighted interpolation of the z-coordinate values of a_points based on the inverse of the distance from each point in a_points.

Definition at line 246 of file AnisotropicInterpolator.cpp.

References AnisotropicDistanceSquared().

Referenced by InterpolatePoint().

◆ ComputeInterpolationPoints()

VecPt3d xms::AnisotropicInterpolator::ComputeInterpolationPoints ( const VecPt3d a_points,
bool  a_pickClosest 
)

Transforms a set of points from normal (x, y, z) coordinates to (s, n, z) coordinates. Note: The z coordinate is left unchanged.

Parameters
[in]a_pointsThe points to transform. (Typically cross sections.)
[in]a_pickClosestTrue to produce only one (s, n, value) for each input point.
Returns
a vector of points in (s, n, z) space. See TransformPoint for a definition of (s, n, z).

Definition at line 152 of file AnisotropicInterpolator.cpp.

References TransformPoint().

Referenced by SetPoints().

◆ CrossProduct()

double xms::AnisotropicInterpolator::CrossProduct ( size_t  a_segmentIndex,
const Pt3d a_p 
) const

Compute the 2d cross product of the vectors from a_p to the 1st and last points in a segment of m_centerLinePts. The cross product will be positive if a_p is to the left of the vector from first to last point in the segment, negative if to the right, and 0.0 if on the line segment.

Parameters
[in]a_segmentIndexThe index of the segment of m_centerlinePts;
[in]a_pA point in (x, y) space (typically in a cross section).
Returns
The 2d cross product.

Definition at line 284 of file AnisotropicInterpolator.cpp.

References m_centerLinePts, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by GetNormalPointParameter(), and AnisotropicInterpolatorUnitTests::testCrossSectionThroughPoint().

◆ Distance()

double xms::AnisotropicInterpolator::Distance ( const Pt3d a_p0,
const Pt3d a_p1 
) const

Compute the distance between two points.

Parameters
[in]a_p0The first point.
[in]a_p1The second point.
Returns
The distance between the points.

Definition at line 207 of file AnisotropicInterpolator.cpp.

References xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by SetPoints(), and TransformPoint().

◆ GetAllNormalPointParameters()

void xms::AnisotropicInterpolator::GetAllNormalPointParameters ( const Pt3d a_p,
VecSNResult a_results 
)

Get the SNResults for a point.

Parameters
[in]a_pThe (x, y, z) point whose parameters are desired.
[out]a_resultsThe vector of SNResult.

Definition at line 393 of file AnisotropicInterpolator.cpp.

References GetNormalPointParameter(), and m_lineParams.

Referenced by TransformPoint().

◆ GetInterpolationPoints()

const VecPt3d & xms::AnisotropicInterpolator::GetInterpolationPoints ( ) const

◆ GetIntersectionOfSegmentWithPoint()

bool xms::AnisotropicInterpolator::GetIntersectionOfSegmentWithPoint ( size_t  a_segmentIndex,
const Pt3d a_p,
Pt3d a_intersection,
double &  a_param 
) const

Get the intersecting point and its parameter of a line through point a_p normal to a segment of m_centerLinePts.

Parameters
[in]a_segmentIndexThe index of a segment of m_centerLinePts.
[in]a_pA point.
[out]a_intersectionThe intersection of a line normal to the segment through a_p.
[out]a_paramThe parameter of the intersection in a range of [0..1] if the intersection is within the segment.
Returns
true if there is an intersection; false otherwise.

Definition at line 339 of file AnisotropicInterpolator.cpp.

References GetParameterInSegment(), xms::LineParameters::Intersection(), m_lineParams, and xms::LineParameters::NormalThrough().

Referenced by GetNormalPointParameter().

◆ GetLineParameters()

LineParameters xms::AnisotropicInterpolator::GetLineParameters ( const Pt3d a_p0,
const Pt3d a_p1 
) const

Compute the 2d slope and intercept for a line through two points.

Parameters
[in]a_p0The first point.
[in]a_p1The second point.
Returns
The LineParameters for the 2d line between the points.

Definition at line 302 of file AnisotropicInterpolator.cpp.

References xms::kVERTICAL, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by SetPoints().

◆ GetNormalPointParameter()

void xms::AnisotropicInterpolator::GetNormalPointParameter ( size_t  a_segmentIndex,
const Pt3d a_p,
double &  a_lastParam,
VecSNResult a_results 
) const

Append the transform (if any) of a point to a centerline segment.

Parameters
[in]a_segmentIndexThe segment of m_centerLinePts.
[in]a_pThe (x, y, z) point to transform.
[in]a_lastParamThe parameter of a_p for the previous segment (a_segmentIndex - 1).
[out]a_resultsA vector a SNResult where the transform will be collected.

Definition at line 362 of file AnisotropicInterpolator.cpp.

References CrossProduct(), GetIntersectionOfSegmentWithPoint(), and m_centerLinePts.

Referenced by GetAllNormalPointParameters().

◆ GetParameterInSegment()

double xms::AnisotropicInterpolator::GetParameterInSegment ( size_t  a_segmentIndex,
const Pt3d a_p 
) const

Compute the parameter for a point in a segment of m_centerLinePts. The parameter will be between 0 and 1 if the normal to the segment through the point is between the segment end points. It will be < 0 if the point projects onto the segment before the first point and > 1 if it projects onto the line after the second point.

Parameters
[in]a_segmentIndexThe index of the segment of m_centerLinePts.
[in]a_pA point whose parameter in that segment is wanted.
Returns
The parametric position of the point within the segment.

Definition at line 322 of file AnisotropicInterpolator.cpp.

References m_centerLinePts.

Referenced by GetIntersectionOfSegmentWithPoint().

◆ InterpolatePoint()

double xms::AnisotropicInterpolator::InterpolatePoint ( const Pt3d a_target,
const VecPt3d a_interpolationPoints,
double  a_xScale,
double  a_IDWPower = 2,
double  a_tol = 1.0e-5 
)

Interpolate the z coordinate of the interpolation points to point a_target.

Parameters
[in]a_targetThe (x, y, z) point whose z coordinate is to be interpolated.
[in]a_interpolationPointsThe points to interpolate from (presumably in [s, n, v] space).
[in]a_xScaleThe scale factor to apply to the x coordinates when computing anisotropic distance.
[in]a_IDWPowerThe power to apply to the inverse distance weighting.
[in]a_tolIf the distance squared between a_target and a point in a_points is less than or equal to this tolerance, just return the z coordinate of that interpolation point.
Returns
A weighted interpolation of the z-coordinate values of a_points based on the inverse of the distance from each point in a_points.

Definition at line 187 of file AnisotropicInterpolator.cpp.

References CalculateIDW(), TransformPoint(), and XM_NODATA.

Referenced by xms::InterpAnisotropicImpl::InterpToPt(), AnisotropicInterpolatorUnitTests::testAmbiguity(), AnisotropicInterpolatorUnitTests::testCrossSectionThroughPoint(), and AnisotropicInterpolatorUnitTests::testSimple().

◆ SetPoints()

void xms::AnisotropicInterpolator::SetPoints ( const VecPt3d a_centerLinePts,
const VecPt3d a_interpolationPts,
bool  a_pickClosest = false 
)

Set the centerline points to parameterize to.

Parameters
[in]a_centerLinePtsThe centerline points.
[in]a_interpolationPtsThe points to be interpolated from (typically cross sections).
[in]a_pickClosestTrue to only transform interpolation points to the closest x station (or segment) on the centerline. If false, interpolation points will transform to every segment of the centerline where a normal to the segment through the point is between the points defining the segment.

Definition at line 117 of file AnisotropicInterpolator.cpp.

References ComputeInterpolationPoints(), Distance(), GetLineParameters(), m_accLengths, m_centerLinePts, m_lineParams, m_SNPoints, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by xms::InterpAnisotropicImpl::SetPoints(), AnisotropicInterpolatorUnitTests::testAmbiguity(), AnisotropicInterpolatorUnitTests::testCrossSectionThroughPoint(), and AnisotropicInterpolatorUnitTests::testSimple().

◆ TransformPoint()

VecPt3d xms::AnisotropicInterpolator::TransformPoint ( const Pt3d a_p,
bool  a_onlyClosest = false 
)

Transforms a point from (x, y, z) to (s, n, z) coordinates. s is for station (distance along the centerline) and n for normal (perpendicular distance) to a segment to m_centerLinePts. The z coordinate is left unchanged.

Parameters
[in]a_pThe (x, y, z) point to transform.
[in]a_onlyClosestTrue to return only one (the closest) (s, n, z) point.
Returns
A vector of (s, n, z) points corresponding to a_p. Conceptually, the centerline is straightened out to lie along the x axis, with this first point at x = 0. The point will be projected via a normal through it onto each centerline segment. Their s-value will be the accumulated distance along the centerline to that intersection. The n-value will be the distance along that normal. It will be positive if the point is to the left of the segment and negative if to the right. A (s, n, z) point will be generated for each segment where the normal is between the segment end points. If a_onlyClosest is true, only the (s, n, z) point with the smallest absolute value of n will be returned.

Definition at line 421 of file AnisotropicInterpolator.cpp.

References Distance(), GetAllNormalPointParameters(), m_accLengths, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by ComputeInterpolationPoints(), xms::InterpAnisotropicImpl::GetTransformedPts(), InterpolatePoint(), AnisotropicInterpolatorUnitTests::testAmbiguity(), AnisotropicInterpolatorUnitTests::testCrossSectionThroughPoint(), and AnisotropicInterpolatorUnitTests::testSimple().

Member Data Documentation

◆ m_lineParams

std::vector<LineParameters> xms::AnisotropicInterpolator::m_lineParams

LineParameters for each centerline segment.

Definition at line 149 of file AnisotropicInterpolator.h.

Referenced by GetAllNormalPointParameters(), GetIntersectionOfSegmentWithPoint(), and SetPoints().


The documentation for this class was generated from the following files: