예제 #1
0
 public LineSegment(PointF start, PointF end) : base(Angle.ATan(start.subtract(end).Quotient()).Normalize(), new PointF(0, 0))
 {
     this.Points = new Tuple <PointF, PointF>(start, end);
 }
예제 #2
0
            public override bool iswithinbounds(PointF p)
            {
                Angle ang = Angle.ATan(p.subtract(this.Origin).Quotient()).Normalize();

                return((ang - this.Slope).InUnits(Angle.Turn).abs() <= 0.1);
            }
예제 #3
0
        /// <summary>
        /// if polar, v1 is Angle in radians, v2 is Tadius
        /// if rect, v1 is real, v2 is imaginary
        /// </summary>
        public ComplexNumber(double v1, double v2, ComplexRepresentations r = ComplexRepresentations.Rectangular)
        {
            switch (r)
            {
            case ComplexRepresentations.Rectangular:
                _real   = new Lazy <double>(() => v1);
                _imag   = new Lazy <double>(() => v2);
                _radius = new Lazy <double>(() => Math.Sqrt(RealPart * RealPart + ImaginaryPart * ImaginaryPart));
                _angle  = new Lazy <Angle>(() => Radius == 0 ? new Angle(0, Angle.Turn) : Angle.ATan(ImaginaryPart, RealPart));
                break;

            case ComplexRepresentations.Polar:
                if (v2 < 0)
                {
                    v2 = -v2;
                    v1 = v1 + Math.PI / 2;
                }
                _radius = new Lazy <double>(() => v2);
                _angle  = new Lazy <Angle>(() => Radius == 0 ? new Angle(0) : new Angle(v1, true));
                _real   = new Lazy <double>(() => Radius * Angle.Cos());
                _imag   = new Lazy <double>(() => Radius * Angle.Sin());
                break;

            default:
                throw new Exception("unrecognized representation");
            }
        }