Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Programming

Name: Anonymous 2014-05-22 2:15

Points, lines, circles.

Go.

Name: Anonymous 2014-05-22 3:33

>>1-kun

e-eh...?


P(x,y)
C -> x^2 + y^2 = R^2
L -> Ax + By = C

Name: Anonymous 2014-05-22 4:28

>>2
I should have added:
Generate points from line-line, line-circle and circle-circle intersections.
Generate lines by connecting 2 points.
Generate circles from a center point and a circumference point.

Name: Anonymous 2014-05-22 4:54

>>2-kun

A-ahh, o-okay.

F-first you start by de-defining a function that stores the, um, the constants in the equa.. *blushes* I'M SORRY I HAVE TO GO *runs back home*

Name: Anonymous 2014-05-22 6:18

Name: Anonymous 2014-05-22 8:08

line-circle: uses lpa, lpb, cpr, cr (*line circle point radius)

x = dist |lpa - cpr| // y = dist |lpb - cpr|

x > y // if y < cr < x intersection @ cr - y from y heading x

=)

Name: Anonymous 2014-05-22 8:23

*from lpb heading lpb->lpa

oh, and then if both points are outside the radius, you can just put a point on the line inside the circle?

Name: Anonymous 2014-05-22 8:42

so.. line-circle-intersect = lpb * z + lpa * (1 - z)
where z = (cr - y) / (x - y) for y < cr < x ? =D

Name: Anonymous 2014-05-22 10:27

circle-circle gives a wonky triangle with sides cr1, cr2, dist|cpr1 - cpr2|...
can you go a^2 + b^2 ~= 2 * (c/2)^2 + 2 * h^2 ?

Name: Anonymous 2014-05-22 11:27

Luke is easily identifiable by his trademark ellipsis. The emoticons are a sufficient (but not necessary) condition too.

Name: Anonymous 2014-05-22 16:47

A point is a pair of coordinates (x,y)
A line is the set of points starting at A, moving in the direction of B: { A + (B-A)u in R^2 | u in R }
letting u range over all real numbers gives you an infinitely long line, letting u range over the interval [0,1] gives you the line segment from A to B.
A circle is the set of points at some fixed radius r from a central point C, by pythagoras theorem { (x,y) in R^2 | (Cx-x)^2 + (Cy-y)^2 = r^2 }

--------------------------------------------------------------

The intersection of line AB = { A + (B-A)u in R^2 | u in R } with CD = { C + (D-C)v in R^2 | v in R } is the intersection of the sets of points. To find this we need to find the (u,v) where A + (B-A)u = C + (D-C)v. Split this equation into x and y compoenents:

* Ax + (Bx-Ax)u = Cx + (Dx-Cx)v
* Ay + (By-Ay)u = Cy + (Dy-Cy)v

solve for v

* [(Ax-Cx)/(Dx-Cx)] + [(Bx-Ax)/(Dx-Cx)]u = v
* [(Ay-Cy)/(Dy-Cy)] + [(By-Ay)/(Dy-Cy)]u = v

solve for u

* ([(Ax-Cx)/(Dx-Cx)] - [(Ay-Cy)/(Dy-Cy)]) / ([(By-Ay)/(Dy-Cy)]u - [(Bx-Ax)/(Dx-Cx)]) = u

Therefore an intersection occurs when the denominator is nonzero, and you may recover the original point by A + (B-A)u

--------------------------------------------------------------

To find the intersection points between a line and a circle you proceed in the same way:

We need to find values of u for which (Cx - Ax - (Bx-Ax)u)^2 + (Cy - Ax - (By-Ay)u)^2 = r^2

expanding this out in full gives a quadratic equation in u, therefore a line and circle can have 0, 1 or 2 points of intersection

Circle-Circle intersection is done similarly.

Exercise: Write an itneractive GUI program that allows the user to create geometric constructions from these primitives.

Name: Anonymous 2014-05-22 17:55

>>5
LTU?

Don't change these.
Name: Email:
Entire Thread Thread List