Hey guys so today in my math class we started learning about coordinate geometry, and how to figure out the distance between one point and another heres an example of coordinate geometry. I figured this would be useful to someone who wanted to find the distance between two entities in their game or something.

If we were given that picture in maths we would have to work on the distance between point A (0, -1) and point B (4,1). The general formula we are given to work this out is as follows (This follows Pythagoras theorem).

AB² = (x1 - x2)² + (y1 - y2)²

x1 = x coordinate of first point (0)
x2 = x coordinate of second point (4)

y1 = y coordinate of first point (-1)
y2 = y coordinate of second point (1)

So to work it out you need to substitute.

AB² = (0 - 4)² + (-1 - 1)²

Then simplify

AB² = (-4)² + (-2)²
= 16 + 4
= 20

Then you need to move the ² to the other side and change the operator. So we will need to Square root the 20

AB = 4.4 (1dp)

So that is how to calculate the distance between two points. Now if you wanted to use this math in a programming language such as java. you would do the following, or something like this.

public void calcDistance(int x1, int y1, int x2, int y2) {
double distance;
distance = (x1 - x2)^2 + (y1 - y2)^2;
distance = Math.sqrt(distance);
return distance;
}

I'm not an awesome java coder so I don't know if that code would be 100% correct but yeah. Hopefully this helps some people :happy.gif: Also i'm sorry if my math isn't correct, but that is how we are taught in my country.

We learn't that in ninth grade, and our grades go like this
1-6 is like a first school, 6-9 is like high school and then you decide yourself where you want to go.

So 9th grade is last year of High school, correct? In my country we have years 1-6 in first school, then 7-8 in intermediate school and the finally 9-13 in high school. I am currently year 12 :smile.gif:

Sine, cosine, and tangent. First learned it in 8th grade but retook the class this year(sophomore year). But why is this in computers and technology?

Because I have kind of made a tutorial on how to implement this into a Java game, and programming is related to Computers/Technology. This wasn't just a math tutorial, you go to school for that :happy.gif:

So 9th grade is last year of High school, correct? In my country we have years 1-6 in first school, then 7-8 in intermediate school and the finally 9-13 in high school. I am currently year 12 :smile.gif:

Wait you're in 12th grade and just learned distance formula :mellow.gif: We learned that in 7th grade. Oh and by the way in your code, you can simplify from:

Learned it in 6th grade bitches! But only basic knowledge, really started to use and understand it in 7-8th grade.

Yea same, it's like in the first year of a foreign language class the teacher just hands you a list and you memorize it, have no idea what the hell any of it means

Honestly? If you care so much about my grammar, punctuation or spelling. Buy me a dictionary. I don't post on these forums to get flamed by people complaining about my spelling.

Wait you're in 12th grade and just learned distance formula :mellow.gif: We learned that in 7th grade. Oh and by the way in your code, you can simplify from:

If we were given that picture in maths we would have to work on the distance between point A (0, -1) and point B (4,1). The general formula we are given to work this out is as follows (This follows Pythagoras theorem).

x1 = x coordinate of first point (0)

x2 = x coordinate of second point (4)

y1 = y coordinate of first point (-1)

y2 = y coordinate of second point (1)

So to work it out you need to substitute.

Then simplify

Then you need to move the ² to the other side and change the operator. So we will need to Square root the 20

So that is how to calculate the distance between two points. Now if you wanted to use this math in a programming language such as java. you would do the following, or something like this.

I'm not an awesome java coder so I don't know if that code would be 100% correct but yeah. Hopefully this helps some people :happy.gif: Also i'm sorry if my math isn't correct, but that is how we are taught in my country.

Thanks.

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

Good to know :smile.gif: Yea thats what i'm trying to get into next year in school. The class I'm in right now is "Advanced Mathematics"

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

So 9th grade is last year of High school, correct? In my country we have years 1-6 in first school, then 7-8 in intermediate school and the finally 9-13 in high school. I am currently year 12 :smile.gif:

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

Oh wow none of you are from America are you?

Elementary is k-5

Middle school is 6-8

High School is Frosh-Senior(4 years)

i5 6600k 4.6ghz / MSI 280X / 8Gb 2666 DDR4 / Gigabyte Z170X-UD5 / TX550M / 500Gb 850 EVO / NZXT S340 / Corsair K65 / Corsair M60

Because I have kind of made a tutorial on how to implement this into a Java game, and programming is related to Computers/Technology. This wasn't just a math tutorial, you go to school for that :happy.gif:

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

Interested in a FOSS multiplayer minecraft-inspired strategy game? I'm currently making one. Comments welcome.

Yea I know right, I was stunned when I learn't it.. I started to think of the possibilities.

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

Learned it. No other way to say it.

i5 6600k 4.6ghz / MSI 280X / 8Gb 2666 DDR4 / Gigabyte Z170X-UD5 / TX550M / 500Gb 850 EVO / NZXT S340 / Corsair K65 / Corsair M60

Sorry to sound like an asshole. But I don't come onto this forum to fall prey to a grammar nazi. Thanks :smile.gif:

Want a place to advertise your Minecraft server? try MyMCStatus.net now!

Mind = ****ed.

Wait you're in 12th grade and just learned distance formula :mellow.gif: We learned that in 7th grade. Oh and by the way in your code, you can simplify from:

Distance = (x-x1)^2 + (y-y1)^2

Distance = Math.sqrt(Distance)

to

Distance = Math.sqrt(((x-x1)^2 + (y-y1)^2))

Learned it in 6th grade bitches! But only basic knowledge, really started to use and understand it in 7-8th grade.

i5 6600k 4.6ghz / MSI 280X / 8Gb 2666 DDR4 / Gigabyte Z170X-UD5 / TX550M / 500Gb 850 EVO / NZXT S340 / Corsair K65 / Corsair M60

Yea same, it's like in the first year of a foreign language class the teacher just hands you a list and you memorize it, have no idea what the hell any of it means

That was a while ago.

horahora~I'm 16.

Honestly? If you care so much about my grammar, punctuation or spelling. Buy me a dictionary. I don't post on these forums to get flamed by people complaining about my spelling.

No no no. My countries schooling system is different. As well as the teaching methods and when you get taught things.

Thanks. We learn't Pythagoras 2 years ago. But coordinate geometry is a new topic to me.

Want a place to advertise your Minecraft server? try MyMCStatus.net now!