本文整理汇总了C++中Point2d::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2d::GetLength方法的具体用法?C++ Point2d::GetLength怎么用?C++ Point2d::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2d
的用法示例。
在下文中一共展示了Point2d::GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetXShift
TerrainRangeArc::TerrainRangeArc(const Arc2d & data, AxisType width)
{
const Point2d vec = data.start - data.center;
const AxisType radii = vec.GetLength();
const AxisType radiiMax = radii + width / 2;
const AxisType radiiMin = (width / 2 < radii) ? radii - width / 2 : 0;
const int iMin = utils::FloatFloorToInt(-radiiMax);
const int iMax = utils::FloatCeilToInt(radiiMax);
const int iRadiiMin = utils::FloatFloorToInt(radiiMin);
for (int i = iMin; i <= iMax; ++i)
{
const AxisType xMax = GetXShift(i, iMax);
if (std::abs(i) >= iRadiiMin)
{
ProcessRange(vec, data.angle, i, AxisPairType(-xMax, xMax), data.center);
}
else
{
const AxisType xMin = GetXShift(i, iRadiiMin);
const int lxMin = utils::FloatCeilToInt(-xMin);
const int rxMin = utils::FloatFloorToInt(xMin);
if (lxMin == rxMin)
{
ProcessRange(vec, data.angle, i, AxisPairType(-xMax, xMax), data.center);
}
else
{
ProcessRange(vec, data.angle, i, AxisPairType(-xMax, (float)lxMin), data.center);
ProcessRange(vec, data.angle, i, AxisPairType((float)rxMin, xMax), data.center);
}
}
}
}
示例2:
void
RailRoadSplitter::Visit(RailRoadArc & rra)
{
RailRoadParametersTaker rrpt;
rra.Accept(rrpt);
const Point3d start = rrpt.GetStart();
const Point2d start2d = Point2d::Cast(start);
const Point3d & end = rrpt.GetEnd();
const Point2d & center = rra.GetCenter();
const float zShift = rra.GetZShift();
const Rotation rotation = utils::GetAngleRotation(rra.GetAngle());
const Angle absAngle = utils::GetAngleAbs(rra.GetAngle());
const Point2d shiftedStart = start2d - center;
const float radiiFromStart = shiftedStart.GetLength();
using SortedPointsMap = std::map<Angle, Point3d>;
SortedPointsMap sortedPoints;
boost::for_each(splitPoints_,
[&](Point3d p)
{
if (start == p || end == p)
{
return;
}
const Point2d shiftedSplit = Point2d::Cast(p) - center;
const float radiiFromSplit = shiftedSplit.GetLength();
// ignore split point not on the arc
if (!utils::CheckNear(radiiFromSplit, radiiFromStart, 0.0001f))
{
return;
}
const Angle angleToSplit = utils::GetRotationAngle360(shiftedStart, shiftedSplit, rotation);
if (angleToSplit > absAngle)
{
return;
}
p.z() = start.z() + zShift * angleToSplit / absAngle;
sortedPoints.emplace(angleToSplit, p);
});
// if no points did a split, then nothing to return
// ignore points not on the arc and points outside of the arc
if (sortedPoints.empty())
{
return;
}
sortedPoints.emplace(absAngle, end);
Angle prevAngle;
Point3d startPoint = start;
boost::for_each(sortedPoints,
[&](const SortedPointsMap::value_type & v)
{
spitResult_.push_back(RailRoadFactory::Arc(startPoint, utils::GetAdjustedAngleByRotation(v.first - prevAngle, rotation), rra.GetCenter(), v.second.z() - startPoint.z()));
startPoint = v.second;
prevAngle = v.first;
});
}