示例#1
0
        public double AngleTo(Vector other)
        {
            var dotProduct = DotProduct(other);
            var crossProduct = CrossProduct(other);

            var angle = Math.Acos(
                dotProduct / (Length * other.Length)
            ).ToDegrees();

            var otherWay = crossProduct < 0;
            return otherWay ? (360 - angle) : angle;
        }
示例#2
0
        private double SliderAngle(PointerRoutedEventArgs e)
        {
            var centre = new Point(
                ActualWidth / 2, ActualHeight / 2
            );

            var thumb = e.GetCurrentPoint(this)
                .Position.RelativeTo(centre);

            var vertical = new Vector(0, -1);
            return thumb.AngleTo(vertical);
        }
示例#3
0
        private double HalfAngle(Size size, double radius)
        {
            var thickness = (double)GetValue(Halo.ThicknessProperty);

            var width = new Vector(
                Math.Cos(Offset.ToRadians()) * size.Width,
                Math.Sin(Offset.ToRadians()) * size.Height
            ).Length;

            var height = new Vector(
                Math.Sin(Offset.ToRadians()) * size.Width,
                Math.Cos(Offset.ToRadians()) * size.Height
            ).Length;

            return Math.Atan2(
                width/2, radius - thickness/2 - height/2
            ).ToDegrees();
        }
示例#4
0
 public double DotProduct(Vector other)
 {
     return (X * other.X) + (Y * other.Y);
 }
示例#5
0
 public double CrossProduct(Vector other)
 {
     return (Y * other.X) - (X * other.Y);
 }