本文整理汇总了C++中ofVec2f::angle方法的典型用法代码示例。如果您正苦于以下问题:C++ ofVec2f::angle方法的具体用法?C++ ofVec2f::angle怎么用?C++ ofVec2f::angle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofVec2f
的用法示例。
在下文中一共展示了ofVec2f::angle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofAngle
float ofAngle(const ofVec2f & vec) {
float ang = vec.angle(ofVec2f(0, -1));
ang -= 180;
ang *= -1;
return ang;
}
示例2: caging
void CageBehavior::caging(vector<RobotState>* robots) {
int n = robots->size();
// update diameter extremities
if (robots->at(1).getTouch()) {
ofVec2f pos = robots->at(1).getPosition();
//ofVec2f goal = robots->at(1).getGoal();
robots->at(1).setGoal(pos);
}
ofVec2f p1 = robots->at(1).getGoal();
ofVec2f goal = ofVec2f(o.x, o.y - cagecenter);
ofVec2f vec = goal - p1;
float orient = vec.angle(ofVec2f(1, 0));
float mag = p1.distance(goal);
o = ofVec2f(p1.x, p1.y+cagecenter);
ofVec2f left = ofVec2f(p1.x - d / 2, p1.y + cagecenter);
ofVec2f right = ofVec2f(p1.x + d / 2, p1.y + cagecenter);
ofVec2f axis = o + (right - o).rotate(-orient);
int start = 2;
start = checksection(orient);
if ((abs(preaxis.angle(axis)) >= 5))
{
pho = pho + 2;
if (pho >= 180)
{
pho = 180;
}
for (int i = 0; i<nmid; i++) {
//
if (i < nmid)
{
int k = i;
float a = pho * (nmid / 2 - 1 - k + 0.5) / (float)(nmid / 2);
ofVec2f p = o + (preaxis - o).rotate(a);
if ((prestart + i) <= 9)
{
robots->at(prestart + i).setGoal(p);
robots->at(prestart + i).setColor(ofColor(0, 0, 255));
}
else
{
robots->at(prestart + i - 8).setGoal(p);
robots->at(prestart + i - 8).setColor(ofColor(0, 0, 255));
}
}
else
{
int k = i - (nmid / 2);
float a = pho * (nmid / 2 - 1 - k + 0.5) / (float)(nmid / 2);
ofVec2f p_ = o + (preaxis - o).rotate(-a);
if ((start + i) <= 9)
{
robots->at(start + i).setGoal(p_);
robots->at(start + i).setColor(ofColor(0, 0, 255));
}
else
{
robots->at(start + i - 8).setGoal(p_);
robots->at(start + i - 8).setColor(ofColor(0, 0, 255));
}
}
}
}
else {
if (mag > 0)
{
pho = pho - 2;
if (pho <= 130)
{
pho = 130;
}
}
else
{
pho = pho + 2;
if (pho >= 180)
{
pho = 180;
}
}
for (int i = 0; i<nmid; i++) {
//
if (i < nmid)
{
int k = i;
float a = pho * (nmid / 2 - 1 - k + 0.5) / (float)(nmid / 2);
ofVec2f p = o + (axis - o).rotate(a);
if ((start + i) <= 9)
{
robots->at(start + i).setGoal(p);
robots->at(start + i).setColor(ofColor(0, 0, 255));
}
//.........这里部分代码省略.........