围绕圆形路径移动点 [英] Move a point around a circular path

查看:93
本文介绍了围绕圆形路径移动点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有2D坐标的点.我需要更改点坐标值才能遵循圆形路径.

I have a point with 2D coordinates. I need to change the points coordinate values in order to follow a circular path.

我将如何使用C来实现呢?

How would I implement that using C?

推荐答案

使用sin和cos

for (double t = 0; t < 2*Pi; t += 0.01) {
    x = R*cos(t) + x_0;
    y = R*sin(t) + y_0;
}

其中:

  • (x_0,y_0)是圆的中心
  • R是raduis

这篇关于围绕圆形路径移动点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆