当前位置: 首页>>代码示例>>C++>>正文


C++ Vector2D::normalized方法代码示例

本文整理汇总了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;
    }
}
开发者ID:doyubkim,项目名称:fluid-engine-dev,代码行数:10,代码来源:custom_implicit_surface2.cpp

示例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;
        }
    }
}
开发者ID:amiryanj,项目名称:cyrus_ssl,代码行数:17,代码来源:planningproblem.cpp

示例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;
}
开发者ID:SDEagle,项目名称:MagBounce,代码行数:22,代码来源:Game.cpp

示例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;
 }
开发者ID:ELMERzark,项目名称:JVGS,代码行数:6,代码来源:Vector2D.cpp


注:本文中的Vector2D::normalized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。