public static Vector Tangent(this Vector v, Vector v1, Vector v2) { double a1 = v1.Angle(); double a2 = v2.Angle(); v = new Vector(v.Length, 0).Rotate(a1 + (a2 - a1) / 2); // double a = v.Angle(); Vector v1b = v1 - v; Vector v2b = v2 - v; double a1b = Vector.AngleBetween(v1b, v); double a2b = Vector.AngleBetween(v, v2b); int i = 0; while (Math.Round(a1b, 10) != Math.Round(a2b, 10)) { if (a2b > a1b) { a1 = v.Angle(); } else if (a1b > a2b) { a2 = v.Angle(); } v = new Vector(v.Length, 0).Rotate(a1 + (a2 - a1) / 2); a1b = Vector.AngleBetween(v1b, v); a2b = Vector.AngleBetween(v, v2b); // a = v.Angle(); // Console.WriteLine("{0} {1} {2}", a1b, a2b, a); i++; } return v; }
public void TestThreeLine() { Vector v = new Vector(3, 0).Tangent(new Vector(10, 0), new Vector(0, 10)); Dictionary<int, double> d = new Dictionary<int, double>(); for (int i = 5; i < 100; i++) { v = new Vector(5, 0).Tangent(new Vector(10, 0), new Vector(0, i)); double a = v.Angle(); d.Add(i, a); } }
private double getFishAngle(Microsoft.Kinect.JointCollection joints) { Point a = getDisplayPosition(joints[JointType.Head]); a = getDisplayPosition(joints[JointType.ShoulderCenter]); Point b = getDisplayPosition(joints[JointType.Spine]); //Point c = new Point(a.X, b.Y + (b.Y-a.Y)); //Point c = Average( //getDisplayPosition(joints[Joint.AnkleLeft]), //getDisplayPosition(joints[Joint.AnkleRight])); //System.Windows.Vector v1 = new System.Windows.Vector(c.X-b.X,c.Y - b.Y); System.Windows.Vector v2 = new System.Windows.Vector(b.X - a.X, b.Y - a.Y); double ang = AngleConstrain(2*(v2.Angle() - 90.0), -30, 30);//AngleConstrain(-NormalizeAngle(180.0 - v2.Angle()), -30, 30); //Console.WriteLine(ang); return ang; }