예제 #1
0
 public ArmSegment(ArmSegment parent, double length, double minAngle, double maxAngle, double angle)
 {
     this.maxAngle = maxAngle * (Math.PI / 180);
     this.minAngle = minAngle * (Math.PI / 180);
     Parent        = parent;
     Length        = length;
     Angle         = angle * (Math.PI / 180);
 }
        /// <summary> Get the absolute position of a given arm segment </summary>
        /// <param name="segment"> The segment </param>
        /// <returns> a vector3 pointing at the absolute position </returns>
        public static Vector3 Forward(ArmSegment segment)
        {
            if (segment.Parent == null)
            {
                return(new Vector3((float)(segment.Length * System.Math.Sin(segment.Angle)),
                                   (float)(segment.Length * System.Math.Cos(segment.Angle)),
                                   0));
            }

            var pos = Forward(segment.Parent);

            return(new Vector3(pos.X + (float)(segment.Length * System.Math.Sin(segment.Angle)),
                               pos.Y + (float)(segment.Length * System.Math.Cos(segment.Angle)),
                               0));
        }