|
|
1. The equation of a line can be expressed as y-k = m*(x-h). m is the slope
of the line (rise/run), and (h,k) is a point on the line.
One point on the line is (2,2). So we'll use 2 for h and k.
The slope of the line is 5/4. (look at your picture, you can see the line
goes up 5 and to the right 4, so we take the rise over the run.)
So the equation of the first line is y-2 = 5/4*(x-2).
The equatoin of the second line is, of course, y=5, since it consists of all
points where y = 5.
The intersection between them can be found easily, since we know that at the
intersection, y=5, and can just plug that into the equation for the other
line:
5-2 = 5/4*(x-2)
3*4/5 = x-2
12/5+2 = x
So the intersection must be at (12/5+2, 5). (You can work out 12/5+2 on your
own =)
2. This one is more difficult. I know from experience that we're going to
end up with a quadratic equation to solve (an equation where the highest
exponent of y or x is two.)
Again, it's a matter of taking the equations of both shapes and finding the
(x,y) values where both of them are true.
The equation of a circle of radius r, centered at (h,k), is (x-h)^2 +
(y-k)^2 = r^2. This is based on pythagorean's theorem.
The equation of this particular circle, therefore, is (x-5)^2 + (y-5)^2 =
4^2.
The equation of the line is y=3.
Again, we can merely substitute 3 in for y in the circle's equation.
(x-5)^2 + (3-5)^2 = 4^2
x^2-10*x+25 + (-2)^2 = 16
x^2 - 10*x + 9 + 4 = 0
x^2 - 10*x + 13 = 0
Heh, it's a quadratic, as I expected. (If you recall, quadratic equations
have either zero, one, or two solutions. In this case, that will correspond
to the line missing the circle entirely, skimming just along its edge, or
intersecting twice. In this case, we can see that it's intersecting twice.)
We'll use the quadratic equation:
x = (-b +/- sqrt(b^2 - 4*a*c))/(2*a)
(Now, if you're not certain that the line will intersect the sphere, then
what you need to do is check (b^2 - 4*a*c). If that is less than zero, then
you'll have a negative inside the square root - which means there is no
solution, and therefore no intersection. If it's equal to zero, then there
will be exactly one solution - the line skims across the edge of the sphere.
And if it's greater than zero, then the +/- takes effect, and we have two
solutions: two intersections.)
Let's substitute our values in:
x = (10 +/- sqrt(100 - 4*1*13))/(2*1)
x = 5 +/- sqrt(48)/2
The square root of 48 is something that you can leave for POV-Ray to work
out.
Now, if you plan on doing this calculation many different times, then you
should do it not with numbers, but rather with variables, out on paper (the
variables would be the slope and x and y values of a point on the line, the
x and y values of the center of the circle, and the radius of the circle. be
sure to give them all separate names that don't include "x", "y", or "z" so
that you don't get confused.). Then find the solution in terms of the
variables, and you'll come up with a single equation that you can type into
povray to easily find the intersections given the variables.
I commend you on your desire to know how to do these without the use of the
trace() function. It will get you farther in the long run.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|