Ejemplo n.º 1
0
 /// <summary>
 /// Gets hypotenuse from a known side and the angle adjacent to that side.
 /// </summary>
 /// <param name="side">Length of the known side.</param>
 /// <param name="angleAdjacentToSide">The angle adjacent to the known side in degrees.</param>
 public static decimal GetHypFromSideAdjAngle(decimal side, decimal angleAdjacentToSide)
 {
     // cos(a) = s / h
     // h * cos(a) = s
     // h = s / cos(a)
     return(side / DecimalEx.Cos(DecimalEx.ToRad(angleAdjacentToSide)));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a line segment of length 1 starting at the point on the circle
        /// and extending either clockwise or counterclockwise.
        /// </summary>
        /// <param name="degrees">An angle.</param>
        public LineSeg2D TangentAt(decimal degrees, decimal length, bool clockwise)
        {
            var       r   = RightTriangleAbstract.FromTwoSides(_radius, length);
            decimal   rad = DecimalEx.ToRad(degrees + r.AngleA);
            LineSeg2D ret = default(LineSeg2D);

            Debug.Assert(r.AngleA == RightTriangle.GetAngleFromSides(length, _radius));
            Debug.Assert(r.Hypotenuse == RightTriangle.GetHypFromSides(length, _radius));

            ret.Pt1 = PointAt(degrees);
            if (!clockwise)
            {
                ret.Pt2 = new Point2D(_center.X + r.Hypotenuse * DecimalEx.Cos(rad), _center.Y + r.Hypotenuse * DecimalEx.Sin(rad));
            }
            else
            {
                ret.Pt2 = new Point2D(ret.Pt1.X - (_center.X + r.Hypotenuse * DecimalEx.Cos(rad) - ret.Pt1.X), ret.Pt1.Y - (_center.Y + r.Hypotenuse * DecimalEx.Sin(rad) - ret.Pt1.Y));
            }

            return(ret);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the coordinates of the point on the circle at the given angle.
        /// </summary>
        /// <param name="degrees">The angle in degrees.</param>
        public Point2D PointAt(decimal degrees)
        {
            decimal rad = DecimalEx.ToRad(degrees);

            return(new Point2D(_center.X + _radius * DecimalEx.Cos(rad), _center.Y + _radius * DecimalEx.Sin(rad)));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets a side from the adjacent angle and the length of the hypotenuse.
 /// </summary>
 /// <param name="adjacentAngle">Angle adjacent to the side to calculate in degrees.</param>
 /// <param name="hypotenuse">Length of the hypotenuse.</param>
 public static decimal GetSideFromAdjAngleHyp(decimal adjacentAngle, decimal hypotenuse)
 {
     // cos(adjacentAngle) = x / hypotenuse
     // x = hypotenuse * cos(adjacentAngle)
     return(hypotenuse * Convert.ToDecimal(DecimalEx.Cos(DecimalEx.ToRad(adjacentAngle))));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets a side from the opposite angle and the length of the opposite side.
 /// </summary>
 /// <param name="oppositeAngle">Angle opposite the side to calculate in degrees.</param>
 /// <param name="oppositeSide">Length of the opposite side.</param>
 public static decimal GetSideFromOppAngleOppSide(decimal oppositeAngle, decimal oppositeSide)
 {
     // tan(oppositeAngle) = x / oppositeSide
     // x = oppositeSide * tan(oppositeAngle)
     return(oppositeSide * Convert.ToDecimal(DecimalEx.Tan(DecimalEx.ToRad(oppositeAngle))));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets a side from the adjacent angle and the length of the opposite side.
 /// </summary>
 /// <param name="adjacentAngle">Angle adjacent to the side to calculate in degrees.</param>
 /// <param name="oppositeSide">Length of the opposite side.</param>
 public static decimal GetSideFromAdjAngleOppSide(decimal adjacentAngle, decimal oppositeSide)
 {
     // tan(adjacentAngle) = oppositeSide / x
     // x = oppositeSide / tan(adjacentAngle)
     return(oppositeSide / Convert.ToDecimal(DecimalEx.Tan(DecimalEx.ToRad(adjacentAngle))));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets hypotenuse from a known side and the angle opposite to it.
 /// </summary>
 /// <param name="side">Length of the known side.</param>
 /// <param name="angleOppositeToSide">Angle opposite to the known side in degrees.</param>
 public static decimal GetHypFromSideOppAngle(decimal side, decimal angleOppositeToSide)
 {
     // sin(a) = s / h
     // h = s / sin(a)
     return(side / DecimalEx.Sin(DecimalEx.ToRad(angleOppositeToSide)));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets a side from the opposite angle and the length of the hypotenuse.
 /// </summary>
 /// <param name="oppositeAngle">Angle opposite to the side to calculate in degrees.</param>
 /// <param name="hypotenuse">Length of the hypotenuse.</param>
 public static decimal GetSideFromOppAngleHyp(decimal oppositeAngle, decimal hypotenuse)
 {
     // sin(oppositeAngle) = x / hypotenuse
     // x = hypotenuse * sin(oppositeAngle)
     return(hypotenuse * Convert.ToDecimal(DecimalEx.Sin(DecimalEx.ToRad(oppositeAngle))));
 }