I have two points (x1,y1) and (x2,y2). I want to know whether the points are within 5 meters of one another.
C# – Calculating the distance between 2 points
c
Related Topic
- C# – Deep cloning objects
- C# – How to enumerate an enum
- C# – Catch multiple exceptions at once
- C# – What are the correct version numbers for C#
- C# – Case insensitive ‘Contains(string)’
- C# – Calculate difference between two dates (number of days)
- C# – How to remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning
- C# – Call one constructor from another
Best Answer
If you are using
System.Windows.Point
data type to represent a point, you can useUpdate 2017-01-08:
Point.Subtract
is System.Windows.Vector and it has also propertyLengthSquared
to save onesqrt
calculation if you just need to compare distance.WindowsBase
assembly may be needed in your projectExample with
LengthSquared
and operators