#What Should I Study to Understand These Equations?

15 messages · Page 1 of 1 (latest)

gleaming dirge
#

I got as far as setX and then got stuck.
I'm not really looking for someone to solve it for me. I just want to know what topics I should study so I can understand how to write these equations myself.

Method named distance without any parameters, it needs to return the distance between this Point and Point (0, 0) as a double.

Method named distance with parameter of type Point, it needs to return the distance between this Point and the parameter Point as a double.

Method named distance with two parameters x, y both of type int, it needs to return the distance between this Point and Point x, y as a double.

How to find the distance between two points?
To find a distance between points A(xA,yA) and B(xB,yB), we use the formula:

d(A,B)=√ (xB − xA) * (xB - xA) + (yB − yA) * (yB - yA)

dense ledgeBOT
#

<@&987246399047479336> please have a look, thanks.

tender quartz
#

not sure i get what ur asking

#

are u trying to implement sth like:

#
public static double distance(Point a, Point b) {
  return ...
}
#

Math.sqrt((b.getX() - a.getX()) * ...)

#

its fairly straightforward

#

u just call ur getters

#

what ur looking at is the normal straight line distance

#

also called euclidean distance

#

which, for 2-dimensions, is given by the above formula

#

derived from the pythagorean theorem

#

which u might remember from school:

gleaming dirge