|
![](/i/fill.gif) |
Here is a file that I wrote that does it a little bit differently. It
calculates the three vectors for the sides of the triangle. Then it
picks a point inside the triangle by multiplyng one edge vector by a
random number between 0 and 1, finding the vector to the opposite
corner, and then multiplying that by a random number between 0 and 1.
This always yields a point inside the triangle. Then it calculates the
perpendicular distances to the three edges and uses the smallest
distance for the radius.
camera{
location <4,4,-10>
look_at <0,0,0>
}
light_source{
<10,7,-20>
color rgb <1,1,1>
}
#declare P1 = <-3,-3,0> \\ put your three points here
#declare P2 = <0,4,0>
#declare P3 = <3,0,0>
#declare A=seed(3)
#declare vec1 = P2-P1
#declare vec2 = P3-P2
#declare vec3 = P1-P3
#declare counter = 0
#while (counter < 300)
#declare some_center = P1 + rand(A)*((vec2 * rand(A))+vec1)
#declare dist_vec1 = vlength(
vcross(vec1,(some_center-P2)))/vlength(vec1)
#declare dist_vec2 = vlength(
vcross(vec2,(some_center-P3)))/vlength(vec2)
#declare dist_vec3 = vlength(
vcross(vec3,(some_center-P1)))/vlength(vec3)
sphere{
some_center, min(dist_vec1, min(dist_vec2,dist_vec3) )
\\ draw a circle that touches the edge of the
triangle
pigment{ color rgb <0,1,1>}
}
#declare counter = counter + 1
#end
triangle{
P1, P2, P3
pigment { color rgb <1,1,1> }
}
Post a reply to this message
|
![](/i/fill.gif) |