本文整理汇总了C++中Vector2D::normalized方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2D::normalized方法的具体用法?C++ Vector2D::normalized怎么用?C++ Vector2D::normalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2D
的用法示例。
在下文中一共展示了Vector2D::normalized方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closestPointLocal
Vector2D CustomImplicitSurface2::closestNormalLocal(
const Vector2D& otherPoint) const {
Vector2D pt = closestPointLocal(otherPoint);
Vector2D g = gradientLocal(pt);
if (g.lengthSquared() > 0.0) {
return g.normalized();
} else {
return g;
}
}
示例2: solveInvalidGoalState
void PlanningProblem::solveInvalidGoalState()
{
// TODO : make a strategy for handling this situation
// strategy is to just displace goal point temporally to a valid point
for(uint i=0; i<stat_obstacles.size(); i++) {
Obstacle* ob = stat_obstacles[i];
if(ob == NULL) continue;
if(hasCollision(goal.goal_point, *ob)) {
Vector2D diff = goal.goal_point.getPosition().to2D() - Vector2D(ob->transform.p);
float displacement_ = agent->radius() + ob->shape->m_radius - diff.lenght();
if(displacement_ > 0)
goal.goal_point.setPosition( goal.goal_point.getPosition() +
(diff.normalized() * displacement_ * 1.1).to3D());
break;
}
}
}
示例3: getCameraPosition
Vector2D Game::getCameraPosition() {
Vector2D move = currentLevel->getPlayerObject()->getPosition() - oldCameraPosition;
if (move.length() > cam_radius) {
oldCameraPosition += move.normalized() * (move.length()-cam_radius);
}
if (oldCameraPosition.getX() + 320 > currentLevel->getWidth()) {
oldCameraPosition.setX(currentLevel->getWidth() - 320);
}
if (oldCameraPosition.getX() < 320) {
oldCameraPosition.setX(320);
}
if (oldCameraPosition.getY() + 240 > currentLevel->getHeight()) {
oldCameraPosition.setY(currentLevel->getHeight() - 240);
}
if (oldCameraPosition.getY() < 240) {
oldCameraPosition.setY(240);
}
// TODO use Display size etc
return oldCameraPosition;
}
示例4: acos
float Vector2D::getAngle(const Vector2D &other) const
{
float abs = acos(normalized() * other.normalized());
abs = 180.0f * abs / M_PI;
return x * other.y - y * other.x >= 0.0f ? abs : -abs;
}