我得到一个半径为 R 的圆,它的中心在点 (0,0) 和一个点 P(x,y),位于圆上 (x*x+y*y=R*R)。我必须在圆上以 Z 角顺时针方向移动点 P,并找到新点的坐标。有没有任何数学公式可以做到这一点?提前致谢!
问问题
2257 次
3 回答
4
使用极坐标,您可以得出以下结论。
最初假设笛卡尔坐标中的 (x, y) 是极坐标中的 (r, t),方法如下
x = r * cos(t)
y = r * sin(t)
现在让 (x', y') 成为旋转角度 a 后的新点(逆时针)
x' = r * cos(t + a)
y' = r * sin(t + a)
展开它们,你可以得到以下
x' = r * cos (t) * cos (a) - r * sin (t) * sin (a)
y' = r * sin (t) * cos (a) + r * cos (t) * sin (a)
x' = x * cos (a) - y * sin (a)
y' = x * sin (a) + y * cos (a)
现在替换 a = -theta(因为您提到了顺时针方向的 theta),您将获得新点。
于 2012-12-28T18:18:01.630 回答
1
使用此类的极坐标或推断三角函数:
感兴趣的方法:
/// <summary>
/// Returns polar coordinate converted to 2-d cartesian coordinates.
/// Coordinates are relative to 0,0 of the angle base vertex
/// </summary>
public Point Point
{
get
{
int x = (int)(m_R * Math.Cos(m_Theta));
int y = (int)(m_R * Math.Sin(m_Theta));
return new Point(x, y);
}
}
全班:
/* NFX by ITAdapter
* Originated: 2006.01
* Revision: NFX 0.2 2009.02.10
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
namespace NFX.Geometry
{
/// <summary>
/// Represents a point with polar coordinates
/// </summary>
public struct PolarPoint
{
#region .ctor
/// <summary>
/// Initializes polar coordinates
/// </summary>
public PolarPoint(double r, double theta)
{
m_R = r;
m_Theta = 0;
Theta = theta;
}
/// <summary>
/// Initializes polar coordinates from 2-d cartesian coordinates
/// </summary>
public PolarPoint(Point center, Point point)
{
this = CartesianUtils.PointToPolarPoint(center, point);
}
#endregion
#region Private Fields
private double m_R;
private double m_Theta;
#endregion
#region Properties
/// <summary>
/// R coordinate component which is coordinate distance from point of coordinates origin
/// </summary>
public double R
{
get { return m_R; }
set { m_R = value; }
}
/// <summary>
/// Angular azimuth coordinate component. An angle must be between 0 and 2Pi.
/// Note: Due to screen Y coordinate going from top to bottom (in usual orientation)
/// Theta angle may be reversed, that is - be positive in the lower half coordinate plane.
/// Please refer to:
/// http://en.wikipedia.org/wiki/Polar_coordinates
/// </summary>
public double Theta
{
get { return m_Theta; }
set
{
if ((value < 0) || (value > Math.PI * 2))
throw new NFXException("Invalid polar coordinates angle");
m_Theta = value;
}
}
/// <summary>
/// Returns polar coordinate converted to 2-d cartesian coordinates.
/// Coordinates are relative to 0,0 of the angle base vertex
/// </summary>
public Point Point
{
get
{
int x = (int)(m_R * Math.Cos(m_Theta));
int y = (int)(m_R * Math.Sin(m_Theta));
return new Point(x, y);
}
}
#endregion
#region Operators
public static bool operator ==(PolarPoint left, PolarPoint right)
{
return (left.m_R == right.m_R) && (left.m_Theta == right.m_Theta);
}
public static bool operator !=(PolarPoint left, PolarPoint right)
{
return (left.m_R != right.m_R) || (left.m_Theta != right.m_Theta);
}
#endregion
#region Object overrides
public override bool Equals(object obj)
{
if (obj is PolarPoint)
return this==((PolarPoint)obj);
else
return false;
}
public override int GetHashCode()
{
return m_R.GetHashCode() + m_Theta.GetHashCode();
}
public override string ToString()
{
return string.Format("Distance: {0}; Angle: {1} rad.", m_R, m_Theta);
}
#endregion
}
}
于 2012-12-28T18:08:16.153 回答
0
使用笛卡尔到极坐标公式:
x = r*cos(θ)
y = r*sin(θ)
使用弧度并求解起始点和目的地点(您缺少起始点的 theta,而您有目的地点的 delta theta)。
然后转换回笛卡尔:
r^2 = x^2 + y^2
r = sqrt(x^2 + y^2)
theta = arctan(y/x)
可以在http://tutorial.math.lamar.edu/Classes/CalcII/PolarCoordinates.aspx找到一个很好的参考
于 2012-12-28T18:18:23.973 回答