xmsinterp
1.0
|
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 VecPt3d & | GetInterpolationPoints () 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< LineParameters > | m_lineParams |
VecPt3d | m_SNPoints |
The interpolation points. | |
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.
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.
[in] | a_p0 | The first point. |
[in] | a_p1 | The second point. |
[in] | a_xScale | The scale factor to apply to the x coordinate. |
Definition at line 222 of file AnisotropicInterpolator.cpp.
References xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by 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.
[in] | a_xScale | The scale factor to apply to the x coordinates when computing anisotropic distance. |
[in] | a_points | The points to interpolate from (presumably in [s, n, z] space). |
[in] | a_target | The point in (s,n,?) whose z coordinate is to be interpolated. |
[in] | a_power | The exponent to apply to the inverse distance weighting. |
[in] | a_tol | If 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. |
Definition at line 246 of file AnisotropicInterpolator.cpp.
References AnisotropicDistanceSquared().
Referenced by InterpolatePoint().
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.
[in] | a_points | The points to transform. (Typically cross sections.) |
[in] | a_pickClosest | True to produce only one (s, n, value) for each input point. |
Definition at line 152 of file AnisotropicInterpolator.cpp.
References TransformPoint().
Referenced by SetPoints().
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.
[in] | a_segmentIndex | The index of the segment of m_centerlinePts; |
[in] | a_p | A point in (x, y) space (typically in a cross section). |
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().
Compute the distance between two points.
[in] | a_p0 | The first point. |
[in] | a_p1 | The second point. |
Definition at line 207 of file AnisotropicInterpolator.cpp.
References xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by SetPoints(), and TransformPoint().
void xms::AnisotropicInterpolator::GetAllNormalPointParameters | ( | const Pt3d & | a_p, |
VecSNResult & | a_results | ||
) |
Get the SNResults for a point.
[in] | a_p | The (x, y, z) point whose parameters are desired. |
[out] | a_results | The vector of SNResult. |
Definition at line 393 of file AnisotropicInterpolator.cpp.
References GetNormalPointParameter(), and m_lineParams.
Referenced by TransformPoint().
const VecPt3d & xms::AnisotropicInterpolator::GetInterpolationPoints | ( | ) | const |
Get the transformed interpolation points in (s, n, z) space.
Definition at line 167 of file AnisotropicInterpolator.cpp.
References m_SNPoints.
Referenced by xms::InterpAnisotropicImpl::GetInterpolationPts(), xms::InterpAnisotropicImpl::InterpToPt(), AnisotropicInterpolatorUnitTests::testAmbiguity(), AnisotropicInterpolatorUnitTests::testCrossSectionThroughPoint(), and AnisotropicInterpolatorUnitTests::testSimple().
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.
[in] | a_segmentIndex | The index of a segment of m_centerLinePts. |
[in] | a_p | A point. |
[out] | a_intersection | The intersection of a line normal to the segment through a_p. |
[out] | a_param | The parameter of the intersection in a range of [0..1] if the intersection is within the segment. |
Definition at line 339 of file AnisotropicInterpolator.cpp.
References GetParameterInSegment(), xms::LineParameters::Intersection(), m_lineParams, and xms::LineParameters::NormalThrough().
Referenced by GetNormalPointParameter().
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.
[in] | a_p0 | The first point. |
[in] | a_p1 | The second point. |
Definition at line 302 of file AnisotropicInterpolator.cpp.
References xms::kVERTICAL, xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by SetPoints().
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.
[in] | a_segmentIndex | The segment of m_centerLinePts. |
[in] | a_p | The (x, y, z) point to transform. |
[in] | a_lastParam | The parameter of a_p for the previous segment (a_segmentIndex - 1). |
[out] | a_results | A 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().
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.
[in] | a_segmentIndex | The index of the segment of m_centerLinePts. |
[in] | a_p | A point whose parameter in that segment is wanted. |
Definition at line 322 of file AnisotropicInterpolator.cpp.
References m_centerLinePts.
Referenced by GetIntersectionOfSegmentWithPoint().
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.
[in] | a_target | The (x, y, z) point whose z coordinate is to be interpolated. |
[in] | a_interpolationPoints | The points to interpolate from (presumably in [s, n, v] space). |
[in] | a_xScale | The scale factor to apply to the x coordinates when computing anisotropic distance. |
[in] | a_IDWPower | The power to apply to the inverse distance weighting. |
[in] | a_tol | If 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. |
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().
void xms::AnisotropicInterpolator::SetPoints | ( | const VecPt3d & | a_centerLinePts, |
const VecPt3d & | a_interpolationPts, | ||
bool | a_pickClosest = false |
||
) |
Set the centerline points to parameterize to.
[in] | a_centerLinePts | The centerline points. |
[in] | a_interpolationPts | The points to be interpolated from (typically cross sections). |
[in] | a_pickClosest | True 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().
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.
[in] | a_p | The (x, y, z) point to transform. |
[in] | a_onlyClosest | True to return only one (the closest) (s, n, z) point. |
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().
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().