Created
September 14, 2015 14:18
-
-
Save zone117x/26ff4bf00ad0b99bca8d to your computer and use it in GitHub Desktop.
C# Point between two points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void CalculateBetweenPoint(double x1, double y1, double x2, double y2, double distance, out double x3, out double y3) | |
| { | |
| var xDistance = Math.Abs(x1 - x2); | |
| var yDistance = Math.Abs(x2 - y2); | |
| var distanceAB = Math.Sqrt(Math.Pow(xDistance, 2) + Math.Pow(yDistance, 2)); | |
| var angleAB = Math.Atan2(y2 - y1, x2 - x1); | |
| var deltaXAC = distance * Math.Cos(angleAB); | |
| var deltaYAC = distance * Math.Sin(angleAB); | |
| x3 = x1 + deltaXAC; | |
| y3 = y1 + deltaYAC; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment