2012-12-28 111 views
0

我給出了一個半徑爲R,圓心位於圓(x * x + y *)上的點(0,0)和點P(x,y) Y = R * R)。我必須在圓上以順時針方向移動點P,並使用角度Z,並找到新點的座標。有這樣的數學公式嗎?提前致謝!一個圓上一個點的轉換

+1

發現從我粗略瀏覽一下,就在我們e [極座標](http://en.wikipedia.org/wiki/Polar_coordinates#Circle)? –

回答

3

採用極座標,你可以推導如下。

最初假設(X,Y)在笛卡爾是(R,T)在極座標以下列方式

x = r * cos(t) 
y = r * sin(t) 

現在讓(X 'Y')旋轉的後是新分角(逆時針)

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) 

現在替換爲= -theta (因爲你在順時針方向提到theta),你會得到新的點。

+0

非常感謝! – user1907615

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 

    } 


    } 
0

使用笛卡爾座標到極座標公式:

X = R * COS(THETA)

Y = R * SIN(THETA)

使用弧度,解決兩者的始發點和目的地點(您錯過了始發點的theta,並且您有目標點的delta西塔)。

然後轉換回直角座標:

R^2 = X^2 + Y^2

R = SQRT(X^2 + Y^2)

THETA =反正切(Y/X)

一個非常好的參考可以在http://tutorial.math.lamar.edu/Classes/CalcII/PolarCoordinates.aspx

相關問題