-3

I want to know how I can write a method that gets the max distance point that returns the farthest point from the origin [Code][1]

https://i.stack.imgur.com/tzNpE.jpg

  • 2
    Welcome to Stack Overflow. Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then [edit] your question to include the source code you have as a [mcve], which can be compiled and tested by others. Do not post the source code as an image. – Progman Jun 06 '20 at 22:38
  • Please note that this question does not really meet SO quality bar. Since we already have answer how to find element with max/min value of a property (or computed value) I find it acceptable to close as duplicate, also other votes to close as "needs details" are very much correct too. If you feel that the linked duplicate does not explain how to find element of a collection with max value of some property or computed value (like max distance from fixed point) please [edit] the question following @Progman's recommentations. – Alexei Levenkov Jun 06 '20 at 23:11

1 Answers1

0

I assume by origin you mean the first point in the path. And you want to find the point on the path thats furthest away then do this (psuedo code)

orig = path[0] // have to create a pathh accessor
max = 0
point best
for i = 1 to n
  p = path[i]
  dist = orig.distance(p)
  if dist > max
     best = p
     max = dist
pm100
  • 48,078
  • 23
  • 82
  • 145