예제 #1
0
 /// <summary>
 ///  <para>
 ///   Rotates a vector about the origin by an angle given in Radians
 ///   radians.
 ///  </para>
 ///  <para>
 ///   A point (x,y) can be rotated around the origin (0,0) by running it through the following equations 
 ///   to get the new point (x',y'):
 ///   x' = cos(theta)*x - sin(theta)*y 
 ///   y' = sin(theta)*x + cos(theta)*y
 ///   where theta is the angle by which to rotate the point.
 ///  </para>
 /// </summary>
 /// <param name="radians">
 ///  System.Double for the rotation angle in radians.
 /// </param>
 /// <returns>
 ///  Vector representing the newly rotated vector.
 /// </returns>
 public Vector Rotate(double radians)
 {
     var newVector = new Vector(Math.Cos(radians) * X - Math.Sin(radians) * Y,
                                Math.Sin(radians) * X + Math.Cos(radians) * Y);
     return newVector;
 }
예제 #2
0
 /// <summary>
 ///  <para>
 ///   Helper function that adds the components values of
 ///   a point to an existing vector and returns the result
 ///   as a new Point.
 ///  </para>
 /// </summary>
 /// <param name="point">
 ///  System.Drawing.Point containing x,y components to add to vector.
 /// </param>
 /// <param name="vector">
 ///  Vector containing x,y components to be added to point
 /// </param>
 /// <returns>
 ///  System.Drawing.Point of the combined x,y components of vector and point.
 /// </returns>
 public static Point Add(Point point, Vector vector)
 {
     return new Point(point.X + (int)vector.X, point.Y + (int)vector.Y);
 }