本文整理汇总了C++中Coordinate::GetYAsFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::GetYAsFloat方法的具体用法?C++ Coordinate::GetYAsFloat怎么用?C++ Coordinate::GetYAsFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinate
的用法示例。
在下文中一共展示了Coordinate::GetYAsFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Intersection
bool PrimitiveLine::Intersection(const PrimitiveLine &other, Coordinate &intersection) const {
// compute "line vector"
Coordinate myP = points_[1]-points_[0];
// compute normal vector
Coordinate myN(-myP.GetYAsFloat(), myP.GetXAsFloat());
assert(myP*myN == 0);
myN /= myP.length();
// get starting and ending point of other line
Coordinate r = other.GetStartingPoint();
Coordinate s = other.GetEndingPoint();
// are lines parallel?
float value = myN * (s-r);
if(-0.001 <= value && value <= 0.001) {
return false;
}
// calculate "d"
float d = myN * GetStartingPoint();
// calculate parameter of intersection
float t = (d-myN*r)/(myN * (s-r));
// calculate intersection
intersection = r + t*(s-r);
return true;
}
示例2: Distance
float PrimitiveLine::Distance(const Coordinate &point) const {
// compute "line vector"
Coordinate p = points_[1]-points_[0];
// compute normal vector
Coordinate n(-p.GetYAsFloat(), p.GetXAsFloat());
assert(p*n == 0);
n /= p.length();
// compute distance
float dist = n*(point-points_[0]);
return fabs(dist);
}