Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. if (Constraint == VertexConstraint.Angle)
  2. {
  3. if ((crossProduct > 0 && Angle < 0) ||
  4. (crossProduct < 0 && Angle > 0))
  5. Angle = -Angle;
  6. if (Math.Abs(Angle - CalculateAngle()) > Constants.Eps)
  7. {
  8. Point RotatePoint(Point p, double angle, Point center)
  9. {
  10. double s = Math.Sin(angle);
  11. double c = Math.Cos(angle);
  12.  
  13. double cx = center.X;
  14. double cy = center.Y;
  15.  
  16. // translate point back to origin:
  17. p.X -= cx;
  18. p.Y -= cy;
  19.  
  20. // rotate point
  21. double xnew = p.X * c - p.Y * s;
  22. double ynew = p.X * s + p.Y * c;
  23.  
  24. // translate point back:
  25. p.X = xnew + cx;
  26. p.Y = ynew + cy;
  27. return p;
  28. }
  29. //if (PrevConstraint != SideConstraint.None || startVertex == Prev)
  30. // CorrectAngle(Prev, this, Next);
  31. //else if (Prev.PrevConstraint != SideConstraint.None && Next.NextConstraint != SideConstraint.None && startVertex != this)
  32. //{
  33. // void CorrentAngleThisPoint()
  34. // {
  35. // Vector delta = Point.Subtract(Next.ToPoint(), Prev.ToPoint()) / 2;
  36. // double tan = Math.Tan(Angle / 2);
  37. // Vector x = delta / tan;
  38. // double xProduct = (X - Prev.X) * (Next.Y - Prev.Y) - (Next.X - Prev.X) * (Y - Prev.Y);
  39. // if (xProduct < 0)
  40. // {
  41. // x.X *= -1;
  42. // x.Y *= -1;
  43. // }
  44. // delta.X += -x.Y;
  45. // delta.Y += x.X;
  46.  
  47. // X = Prev.X + delta.X;
  48. // Y = Prev.Y + delta.Y;
  49. // }
  50. // CorrentAngleThisPoint();
  51. //}
  52. //else
  53. //{
  54. // Angle = -Angle;
  55. // CorrectAngle(Next, this, Prev);
  56. // Angle = -Angle;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement