targetSpeed, targetVelocity Arrival function
targetSpeed, targetVelocity Arrival function
我很难弄清楚找到目标速度的方程式是什么。我正在使用sf::Vector2f来查找2D游戏中的到达函数。我只需要目标速度的方程式。有人能帮我一下吗?这是我迄今为止所拥有的。
void Steering::Arrival( sf::Vector2f position, sf::Vector2f target, float maxSpeed, float maxAcceleration, float timeToTarget, float slowRadius, float targetRadius, float targetSpeed, double distance, SteeringOutput& steering ){
timeToTarget = 0.1;
steering.linear = target - position;
distance = sqrt( steering.linear.x * steering.linear.x + steering.linear.y * steering.linear.y);
targetSpeed = maxSpeed * distance / slowRadius;
//Check if arrived at target
if (distance < targetRadius)
{
MathHelper::ZeroVector;
}
//Check if we are out of the slowRadius
if (distance > slowRadius)
{
targetSpeed = maxSpeed;
}
else
{
targetSpeed = maxSpeed * distance / slowRadius;
}
提前谢谢。
目标速度=(从位置到目标的单位矢量)*(目标速度)。如果您需要一些预先定位,请搜索"卡尔曼滤波器"
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- Confusion: decltype vs std::function
- 为什么 std::function 可以作为 std::not2 的参数?
- 'max'匹配'std::function<const int &(const int &, const int &)>'无过载
- 传递给std::function template的template参数究竟代表什么
- 将带有unique_ptr的可变 lambda 传递给 const&std::function
- 绑定派生类方法C++从实例范围之外的分隔 std::function 变量调用
- "no matching function for call to 'Vector::Vector'"错误
- 如何在向量中删除 std::function<void()>?
- 不断"Attempting to reference a deleted function"
- 将函数包装器转换为 std::function
- 类型擦除的std::function与虚拟函数调用的开销
- C++ std::function 对于类 exept 的所有实例都是空的(只有 Visual2019 编译器问题)
- 如果模板没有可变参数,则 Lambda 被推导出为 std::function
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 模板规范获取'Ambiguous call to overloaded function'
- 将 lambda 表达式传递给 std::function in C++
- targetSpeed, targetVelocity Arrival function