Jump to content

Hello there,

A group of my friends and I are doing a school project about recreating paint in Java. I wanted to add something unique so i decided that i'll a add the possibility to draw a circle that, given three points, touches them. Like so : 
 

27499893_3p1c.jpg

 

I am encountering some problems, not from a logical point of view but when I need to "translate" math language into Java i don't now where to start.

Here's what I would do in math:

  • Find the equation of the line that passes between A and B with the formula c12477cdfdc018efb1fc22307619afbb.gif
  • Do the same for the line that passes between B and C using the same formula
  • Find the "middle point" (I don't know if the term is correct) of AB and BC using the formula be91ccc6a451c4150f75d75ff56759ca.gif
  • I have the m of the equation y = mx +q so I can just obtain the m of the axis by doing the anti reciprocal of the m of the lines that passes between A and B, B and C
  • Obtain the equation of the lines that passes between the middle point (axis) of AB and BC, knowing m using bf5f9a7890045c8192261320506420cf.gif
  • Do a system between the equation of the two axis and find the center of the circle
  • Draw a circle

I only know that for resolving the system it is more convenient to use Cramer's method   but that's the only thing I know.

Any help will be appreciated. If something is not clear feel free to ask, especially if you don't understand something due to linguistic unclarity because I am not an English native speaker. Thanks

Link to comment
https://linustechtips.com/topic/372049-java-and-analytic-geometry/
Share on other sites

Link to post
Share on other sites

you need to find the generic equation of the generic circle that passes through three generic points

the equation of a circle is in the form

(x - a)^2 + (y - b)^2 = r^2

so you need to find the three functions f, g, h so that given three points P1, P2, P3

a = f(P1, P2, P3)b = g(P1, P2, P3)r = h(P1, P2, P3)

at this point it's just a math problem

 

i think that a simpler approach to the problem is to only use the generic equation of a circumference instead of making segments, intersecting them and stuff.

you can insert the coordinates of each of the three points into the equation of the circumference, so that you get a linear system of 3 equations (one for each point) in 3 variables (a, b, r) and you only need to solve that

Link to post
Share on other sites

you need to find the generic equation of the generic circle that passes through three generic points

the equation of a circle is in the form

(x - a)^2 + (y - b)^2 = r^2

so you need to find the three functions f, g, h so that given three points P1, P2, P3

a = f(P1, P2, P3)b = g(P1, P2, P3)r = h(P1, P2, P3)

at this point it's just a math problem

 

i think that a simpler approach to the problem is to only use the generic equation of a circumference instead of making segments, intersecting them and stuff.

you can insert the coordinates of each of the three points into the equation of the circumference, so that you get a linear system of 3 equations (one for each point) in 3 variables (a, b, r) and you only need to solve that

Yeah, you're right. Your method is much more simpler than mine.

Now the big question. How do i resolve three-way system in java ? Cramer's method ?

Link to post
Share on other sites

Yeah, you're right. Your method is much more simpler than mine.

Now the big question. How do i resolve three-way system in java ? Cramer's method ?

it's much more simple than that: you need to work out the generic formula by hand, and you will end up with a formula that you can write down in java as a simple expression

 

so you have three points with generic coordinates:

P1(a, b )

P2(c, d)

P3(e, f)

plug those coordinates in the system and solve it using your favorite method

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×