Vector 如何从矢量点A沿圆周移动n度?(包括图片)
A、 B和中心是二维向量点 n是圆的周长从A到B的长度 我想考B 我在寻找一种方法来弹出a,中心,n和圆的半径来弹出向量点BVector 如何从矢量点A沿圆周移动n度?(包括图片),vector,unity3d,geometry,pi,Vector,Unity3d,Geometry,Pi,A、 B和中心是二维向量点 n是圆的周长从A到B的长度 我想考B 我在寻找一种方法来弹出a,中心,n和圆的半径来弹出向量点B (我使用Mathf在Unity中使用C#进行编码,但我不需要代码作为答案,只需要一些基本步骤就足够了,谢谢)所有角度都以弧度为单位。你的n就是所谓的圆弧 public Vector2 RotateByArc(Vector2 Center, Vector2 A, float arc) { //calculate radius float radius = V
(我使用Mathf在Unity中使用C#进行编码,但我不需要代码作为答案,只需要一些基本步骤就足够了,谢谢)所有角度都以弧度为单位。你的n就是所谓的圆弧
public Vector2 RotateByArc(Vector2 Center, Vector2 A, float arc)
{
//calculate radius
float radius = Vector2.Distance(Center, A);
//calculate angle from arc
float angle = arc / radius;
Vector2 B = RotateByRadians(Center, A, angle);
return B;
}
public Vector2 RotateByRadians(Vector2 Center, Vector2 A, float angle)
{
//Move calculation to 0,0
Vector2 v = A - Center;
//rotate x and y
float x = v.x * Mathf.Cos(angle) + v.y * Mathf.Sin(angle);
float y = v.y * Mathf.Cos(angle) - v.x * Mathf.Sin(angle);
//move back to center
Vector2 B = new Vector2(x, y) + Center;
return B;
}
我想这是为了这样的事情,也许对你有帮助。我想这就是你想要的。该代码也值得赞扬。