本文整理汇总了C++中ofPoint::getInterpolated方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPoint::getInterpolated方法的具体用法?C++ ofPoint::getInterpolated怎么用?C++ ofPoint::getInterpolated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPoint
的用法示例。
在下文中一共展示了ofPoint::getInterpolated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getClosestPointUtil
//----------------------------------------------------------
// http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
static ofPoint getClosestPointUtil(const ofPoint& p1, const ofPoint& p2, const ofPoint& p3, float* normalizedPosition) {
// if p1 is coincident with p2, there is no line
if(p1 == p2) {
if(normalizedPosition != NULL) {
*normalizedPosition = 0;
}
return p1;
}
float u = (p3.x - p1.x) * (p2.x - p1.x);
u += (p3.y - p1.y) * (p2.y - p1.y);
// perfect place for fast inverse sqrt...
float len = (p2 - p1).length();
u /= (len * len);
// clamp u
if(u > 1) {
u = 1;
} else if(u < 0) {
u = 0;
}
if(normalizedPosition != NULL) {
*normalizedPosition = u;
}
return p1.getInterpolated(p2, u);
}
示例2: drawPointOnLine
//--------------------------------------------------------------
void testApp:: drawPointOnLine(ofPoint p1, ofPoint p2, float t){
t = ofClamp(t, 0, 1);
ofPoint circleCenter = p1.getInterpolated(p2, t);
ofCircle(circleCenter, 5);
ofLine(p1, p2);
ofCircle(p1, 3);
ofCircle(p2, 3);
}