Guest User

Untitled

a guest
Jan 11th, 2021
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function TForm1.StraightLine: Tpoint;
  2. var
  3. X,Y : integer;
  4. X2,Y2 : integer;
  5. Slop : real;
  6. Rot : real;
  7. C : real;
  8. Distance : integer;
  9. NewPoint : tpoint;
  10. begin
  11.  
  12. /// Y = MX + C
  13. Distance := 100;
  14. X := StrToInt64(XcordS);
  15. Y := StrToInt64(YCordS);
  16. greenprint(IntToStr(X)+':'+IntToStr(Y));
  17. Y2 := Y + Distance;
  18. X2 := X + Distance;
  19. GreenPrint(IntToStr(X)+':'+IntToStr(Y));
  20.  
  21.  
  22. Facing();
  23. Rot := StrToFloat(GRot);
  24. Rot := Rot / 1000;
  25. Rot := Rot; /// Dont know if this is correct
  26. //Rot := RadToDeg(Rot);
  27. greenprint('ROT: '+FloatToStr(Rot));
  28. Slop := Tan(Rot); /// Converting Degrees to Slop (M)
  29. greenprint('Slop'+':'+FloatToStr(Slop));
  30. // C = -M.X + Y
  31. C := (-Slop*X) + Y;
  32. GreenPrint('C :'+FloatToStr(C));
  33.  
  34.  
  35. NewPoint.X := Round( (Y2 - C) / Slop );
  36. NewPoint.Y := Round((slop*X2) + C);
  37. GreenPrint('NewPoint X: '+IntToStr(NewPoint.X));
  38. GreenPrint('NewPoint Y: '+IntToStr(NewPoint.Y));
  39.  
  40. result := NewPoint;
Advertisement
Add Comment
Please, Sign In to add comment