POV-Ray : Newsgroups : povray.binaries.images : Circumscribed sphere Server Time
1 Nov 2024 00:27:31 EDT (-0400)
  Circumscribed sphere (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Bald Eagle
Subject: Circumscribed sphere
Date: 6 Aug 2014 12:30:01
Message: <web.53e25769ad990c965e7df57c0@news.povray.org>
FractRacer:
Here's a visualization of the goal & problem.

I'm sure I must simply be doing something slightly wrong when I compute a vector
to rotate around, or a normal value, or something.
It all looks fine on paper - so it should work!   :D

If the red torus is the rim of an ice cream cone, then the green sphere should
sit in it perfectly, in full contact, like a scoop of ice cream.

#include "geom_tasks.inc"    <---   analytical_g.inc
#include "drawing.inc"       <---   just an inc I'm working on to make text
always face the camera, draw various kinds of arrows, vectors, shapes, etc.

=============================================================

#version 3.7;
global_settings { assumed_gamma 1.8 }

#include "debug.inc"
 Set_Debug (true)
#declare View_POV_Include_Stack = true;
#include "colors.inc"
#include "math.inc"
#include "shapes.inc"
#include "textures.inc"
#include "transforms.inc"
#include "geom_tasks.inc"
#include "drawing.inc"

#declare verbose = true;


light_source { <2, 20,  5>  color rgb <1,1,1>}

#declare Camera_Origin = camera {
                            location  <0, 0, 0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0.01>}


#declare Camera_Angle = camera {
                            location  <5 , 10, -15.0>
                            //right    x*image_width/image_height
                            //look_at   <0, 0, 0>
                            look_at   <5, 5, 5>}

#declare Camera_Rear = camera {
                            location  <0.0, -100.0, -300.0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}

#declare Camera_Iso = camera {
                            location  <-50, 0, 0>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 0>}

#declare Camera_Top = camera {
                            location  <0, 8.5, 2>
                            //right    x*image_width/image_height
                            look_at   <0, 0, 2>}

#declare Camera_Front = camera {
                            location <25, 4, -2>
                            //right    x*image_width/image_height
                            look_at  <0, 0, 0>}


//camera {Camera_Front }

#declare Camera_Location = <-4, 6, 10>;
#declare Camera_Look_At  = <0, 0,   0>;
#declare LightVector = Camera_Location - Camera_Look_At;
light_source { LightVector*1.2  color rgb <1,1,1>} // Always above and behind
camera to illuminate screen objects
#include "screen.inc"

//
##############################################################################################################


#declare SolidAmbient = 0.6;
#declare FadedAmbient = 0.4;
#declare FadedTrans = 0.7;


#declare SolidRed = texture { pigment {Red} finish {ambient SolidAmbient} };
#declare ShadedRed = texture { pigment {Red transmit FadedTrans} finish {ambient
FadedAmbient} };

#declare SolidYellow = texture { pigment {Yellow} finish {ambient SolidAmbient}
};
#declare ShadedYellow = texture { pigment {Yellow transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare SolidGreen = texture { pigment {Green} finish {ambient SolidAmbient} };
#declare ShadedGreen = texture { pigment {Green transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare SolidBlue = texture { pigment {Blue} finish {ambient SolidAmbient} };
#declare ShadedBlue = texture { pigment {Blue transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare SolidMagenta  = texture {pigment {Magenta} finish { ambient
SolidAmbient phong 1}}
#declare ShadedMagenta = texture { pigment {Blue transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare SolidWhite = texture { pigment {White} finish {ambient SolidAmbient} };
#declare ShadedWhite = texture { pigment {White transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare SolidGray = texture { pigment {Gray50} finish {ambient SolidAmbient} };
#declare ShadedGray = texture { pigment {Gray50 transmit FadedTrans} finish
{ambient FadedAmbient}  };

#declare Line = texture { pigment {Blue} finish {ambient 0.4} };
#declare Line_W = 0.1;
#declare Point = texture { pigment {Blue} finish {ambient 1} };
#declare Point_W = 0.2;
#declare Object = texture { pigment {Yellow} finish {ambient 0.4} };
#declare Plane = texture { pigment {Green}  };

#declare Magenta  = texture {pigment {Magenta} finish { ambient 0.4 phong 1}}


//
##############################################################################################################
//  Screen Overlay

#declare ScreenX = 0;
#declare ScreenY = 1;
#declare Line = 0;
#declare TextSize = 0.035;
#declare TextColor1 = texture {SolidYellow};
#declare TextColor2 = texture {SolidRed};
#declare TextCR = TextSize*1.1;

#declare Top1 = "The goal is to circumscribe the triangle and Point D (a
tetrahedron)"
#declare Top2 = "with a sphere.  The red torus is the correct circumscribed
CIRCLE,"
#declare Top3 = "but the sphere does not contact that circle all the way around,
as it should"
#declare Top4 = "The perpendicular bisector extended from Midpoint to the
centroid normal"
#declare Top5 = "ought to define the center and radius of the desired sphere.
It doesn't."
#declare Screen_Text = text { ttf "arial.ttf", Top1, 0.01, <0, 0> scale TextSize
texture {TextColor1} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Top2, 0.01, <0, 0> scale TextSize
texture {TextColor1} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Top3, 0.01, <0, 0> scale TextSize
texture {TextColor1} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Top4, 0.01, <0, 0> scale TextSize
texture {TextColor1} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Top5, 0.01, <0, 0> scale TextSize
texture {TextColor1} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;

#declare ScreenX = 0.18;
#declare ScreenY = 0.58;
#declare Bottom1 = "#declare Tangent = Triangle_Normal ( Corner_3, Middle,
PointD );"
#declare Bottom2 = "#declare Perp = vcross (PointD-Corner_3, Tangent);"
#declare Bottom3 = "#declare PerpN = vnormalize (Perp);"
#declare Bottom4 = "#declare PerpV = vtransform (Perp*2, transform {translate
Midpoint} );"
#declare Bottom5 = "#declare Adjacent = vlength (Midpoint - PointD);"
#declare Bottom6 = "#declare Theta = VAngleD (Midpoint - PointD, Middle -
PointD);"
#declare Bottom7 = "#declare Opposite = Adjacent * atan (Theta);"
#declare Bottom8 = "#declare Center = vtransform (Midpoint, transform {translate
PerpN * Opposite} );"
#declare Bottom9 = "(I must be using the \"Lucas\" version of screen.inc   ...
:O"

#declare Screen_Text = text { ttf "arial.ttf", Bottom1, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom2, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom3, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom4, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom5, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom6, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom7, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom8, 0.01, <0, 0> scale
TextSize texture {TextColor2} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
#declare Screen_Text = text { ttf "arial.ttf", Bottom9, 0.01, <0, 0> scale
TextSize texture {SolidBlue} }
 Screen_Object ( Screen_Text, <ScreenX, ScreenY-Line>, <0.04, 0.02>, true, 0.1 )
 #declare Line = Line + TextCR;
//
##############################################################################################################

sky_sphere { pigment { gradient y color_map {
            [0.0 rgb <1, 1, 1>]
            [0.8 rgb <1, 1, 1>] } } }




// Origin
sphere {o, 0.1 pigment {White} }

//
##############################################################################################################
//  Gridlines and axes

#macro Raster(RScale, HLine)
 #local Lightness = 0.6;
 pigment{ gradient x scale RScale
                color_map{[0.000   color rgbt<0,0,1,0> * Lightness]
                          [0+HLine color rgbt<0,0,1,0> * Lightness]
                          [0+HLine color rgbt<1,1,1,1>]
                          [1-HLine color rgbt<1,1,1,1>]
                          [1-HLine color rgbt<0,0,1,0> * Lightness]
                          [1.000   color rgbt<0,0,1,0> * Lightness]} }
       finish {ambient 0.1 diffuse 0.9}
#end// of Raster(RScale, HLine)-macro


#macro Grid (RasterScale, RasterHalfLine, Background_pigment)
 plane{<0, 1, 0>, 0      // uses layerd textures!!!!
 texture{Background_pigment  finish { phong 0.1}}
 texture{Raster( RasterScale, RasterHalfLine) rotate<0, 0, 0> }
 texture{Raster( RasterScale, RasterHalfLine) rotate<0, 90, 0>}
       scale 1}
#end

#macro Axis_( AxisLen, RedTexture, WhiteTexture) // ---------------------
 union{
  cylinder {<0,-AxisLen,0>,<0,AxisLen,0>,0.05 texture{checker
texture{RedTexture} texture{WhiteTexture} translate<0.1,0,0.1>}}
  cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0 texture{RedTexture}}
       } // end of union "Axis"
#end // of macro Axis (AxisLen)


#macro AxisXYZ (AxisLenX, AxisLenY, AxisLenZ, TexRed, TexWhite)
 union{
  object{Axis_(AxisLenX, TexRed, TexWhite) no_shadow  rotate< 0,0,-90>}   //
x-Axis
  object{Axis_(AxisLenY, TexRed, TexWhite) no_shadow  rotate< 0,0,  0>}   //
y-Axis
  object{Axis_(AxisLenZ, TexRed, TexWhite) no_shadow  rotate<90,0,  0>}   //
z-Axis
  text{ttf"arial.ttf", "x", 0.15, 0 no_shadow texture{TexRed} scale 0.5
translate <AxisLenX + 0.05, 0.20, -0.12>}
  text{ttf"arial.ttf", "y", 0.15, 0 no_shadow texture{TexRed} scale 0.5
translate <-0.35, AxisLenY + 0.50, -0.05>}
  text{ttf"arial.ttf", "z", 0.15, 0 no_shadow texture{TexRed} scale 0.5
translate <-0.75, 0.2, AxisLenZ + 0.50>}
  } // end of union
#end// of macro "AxisXYZ(...)"



//  Draw Gridlines
object{ Grid ( 1, 0.01, texture {pigment{color rgb <0.5, 0.5, 1>} finish
{ambient 0.3 diffuse 0.9}} )  rotate<0,0,0>}

//  Draw x, y, & z Axes
#declare Tex_Dark  = texture {pigment {color rgb<0, 0, 0.45>} finish { ambient
0.4 phong 1}}
#declare Tex_White = texture {pigment {color rgb<1,1,1>} finish { ambient 0.4
phong 1}}
object{ AxisXYZ (5, 5, 5, Tex_Dark, Tex_White)}

//
##############################################################################################################
//
##############################################################################################################
//  Start Scene description here:

#declare Corner_A_1 = <0, 0, 0>;
#declare Corner_A_2 = <4, 0, 0>;
#declare Corner_A_3 = <4, 4, 0>;
#declare H = 1;

#local AT = text {
ttf "arial.ttf", "A", 0.02, 0.0 // thickness, offset
pigment{ color rgb<1,1,1>*0.5 }
}


#local BT = text {
ttf "arial.ttf", "B", 0.02, 0.0 // thickness, offset
pigment{ color rgb<1,1,1>*0.5 }
}

#local CT = text {
ttf "arial.ttf", "C", 0.02, 0.0 // thickness, offset
pigment{ color rgb<1,1,1>*0.5 }
}


#local DT = text {
ttf "arial.ttf", "d", 0.02, 0.0 // thickness, offset
pigment{ color rgb<1,0.5,0.5> }
scale 0.75
}

#local MT = text {
ttf "arial.ttf", "m", 0.02, 0.0 // thickness, offset
pigment{ color rgb<1,0.5,0.5> }
scale 0.75
}


#local Plane = texture {
pigment {color rgb 0.7}
}

#local Object = texture {
pigment {color rgb <0.7,0.3,0.1>}
}

#local Tex_Dark = texture {
pigment {color rgb <0.17,0.13,0.81>}
}

#local Shaded   = texture {
pigment {color rgb <0.2,0.2,0.2> filter 0.87}
}


#local Rayon = 0.125;

#macro Circumscribed_Sphere (Corner_1, Corner_2, Corner_3, Height)

 union{
  //cylinder {Corner_A_1-0.15*z, Corner_A_1+0.1*z, Rayon  texture {Object} }
  //object {AT translate Corner_A_1-x*1-y*0.5}
  sphere {Corner_A_1, Rayon texture {SolidBlue} }
  object {LabelPoint (Corner_A_1, "A", 0.5) texture {SolidRed} }
  //cylinder {Corner_A_2-0.15*z, Corner_A_2+0.1*z, Rayon  texture {Object} }
  //object {BT translate Corner_A_2+x*0.5-y*0.5}
  sphere {Corner_A_2, Rayon texture {SolidBlue} }
  object {LabelPoint (Corner_A_2, "B", 0.5) texture {SolidRed} }
  //cylinder {Corner_A_3-0.15*z, Corner_A_3+0.1*z, Rayon  texture {Object} }
  //object {CT translate Corner_A_3+x*0.5+y*0.5}
  sphere {Corner_A_3, Rayon texture {SolidBlue} }
  object {LabelPoint (Corner_A_3, "C", 0.5) texture {SolidRed} }

 // POINT P / Middle
 #declare Middle =  Triangle_M_out (Corner_A_1, Corner_A_2, Corner_A_3);
 #declare Radius =  Triangle_R_out (Corner_A_1, Corner_A_2, Corner_A_3);
 #declare Normal =  Triangle_Normal(Corner_A_1, Corner_A_2, Corner_A_3);
 #local TMC = Triangle_Mass_Center(Corner_A_1, Corner_A_2, Corner_A_3);

 //cylinder {Middle-0.15*z, Middle+0.25*z, Rayon  translate Normal texture
{Shaded}}
 //object {MT translate Middle-x*0.5}
 sphere {Middle, Rayon texture {SolidBlue} }
 object {LabelPoint (Middle, "m", 0.5) texture {SolidRed} }
 //cylinder {TMC-0.15*z , TMC +0.1*z, Rayon translate Normal texture {Tex_Dark}}
 sphere {TMC, Rayon texture {SolidBlue} }

 #declare PointD  =  vtransform (Middle, transform {translate Normal*Height});
 object {LabelPoint (PointD, "D", 0.5) texture {SolidRed} translate
Normal*Height}
 //  object {DT translate PointD}

 object {Distance_Marker(Corner_A_1, Corner_A_2, 0.025) texture {SolidMagenta}}
 object {Distance_Marker(Corner_A_2, Corner_A_3, 0.025) texture {SolidMagenta}}
 object {Distance_Marker(Corner_A_3, Corner_A_1, 0.025) texture {SolidMagenta}}
 object {Distance_Marker(Corner_A_1, PointD, 0.025) texture {SolidMagenta}}
 object {Distance_Marker(Corner_A_2, PointD, 0.025) texture {SolidMagenta}}
 object {Distance_Marker(Corner_A_3, PointD, 0.025) texture {SolidMagenta}}

 #declare Midpoint = (Corner_A_3 + PointD)/2;
 sphere {Midpoint, Rayon texture {SolidRed} }
 #declare Tangent = Triangle_Normal ( Corner_3, Middle, PointD );
  // Perpendicular to triangle containing sphere center
  #declare PerpRef = vtransform (Tangent*5, transform {translate Corner_3} ); //
Just a big tangent
  //object {Vector (Corner_3, PerpRef, 0.05) texture {Plane}}
 #declare Perp = vcross (PointD-Corner_3, Tangent);
  #declare PerpN = vnormalize (Perp);
  #declare PerpV = vtransform (Perp*2, transform {translate Midpoint} );
  object {Vector (Midpoint, PerpV, 0.05) texture {SolidGreen}}



 #declare Adjacent = vlength (Midpoint - PointD);
 #declare Theta = VAngleD (Midpoint - PointD, Middle - PointD);
 #declare Opposite = Adjacent * atan (Theta);

 #declare Center = vtransform (Midpoint, transform {translate PerpN * Opposite}
);
  object {Vector (PointD, Center, 0.05) texture {SolidGreen}}

 #declare SRayon = vlength (Center - PointD);

 torus { SRayon,0.05 rotate x*90 translate Middle texture {SolidRed} no_shadow}

 sphere {Center, SRayon texture {ShadedGreen}}

 }  // end union
#end


#declare  Sphere = object {Circumscribed_Sphere (Corner_A_1, Corner_A_2,
Corner_A_3, H) no_shadow};

Sphere


Post a reply to this message


Attachments:
Download 'fractracerfix.png' (235 KB)

Preview of image 'fractracerfix.png'
fractracerfix.png


 

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 6 Aug 2014 14:20:00
Message: <web.53e271833cb258895e7df57c0@news.povray.org>
Grrr.   I wrote "centroid" when I knew I meant "circumcenter".

I was also having some issues depicting the surface normals of the 3 triangles
formed with the original vertices and PointD.


Post a reply to this message

From: FractRacer
Subject: Re: Circumscribed sphere
Date: 7 Aug 2014 14:56:37
Message: <53e3cbe5@news.povray.org>

> FractRacer:
> Here's a visualization of the goal & problem.
>
> I'm sure I must simply be doing something slightly wrong when I compute a vector
> to rotate around, or a normal value, or something.
> It all looks fine on paper - so it should work!   :D
>
> If the red torus is the rim of an ice cream cone, then the green sphere should
> sit in it perfectly, in full contact, like a scoop of ice cream.
>

>

I will take some times to see your code.
If I understand, the point D is not in the same plane as the triangle, 
the torus is - but I may be wrong - the equator of the sphere on which D 
is.

Lionel

-- 
Do not judge my words, judge my actions.

---

http://www.avast.com


Post a reply to this message

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 7 Aug 2014 17:00:01
Message: <web.53e3e8753cb258895e7df57c0@news.povray.org>
> I will take some times to see your code.
> If I understand, the point D is not in the same plane as the triangle,
> the torus is - but I may be wrong - the equator of the sphere on which D
> is.

Correct - D is NOT in the same plane of the triangle.  It is a point H units
away from the triangular plane.
#declare PointD  =  vtransform (Middle, transform {translate Normal*Height});

The center you are using, the "centroid"
#local TMC = Triangle_Mass_Center(Corner_A_1, Corner_A_2, Corner_A_3);
is not the center used for finding the tangent circle.

The "circumcenter"
#declare Middle =  Triangle_M_out (Corner_A_1, Corner_A_2, Corner_A_3);
is the one to use - it also happens to lie on the midpoint between Corner_A_1
and Corner_A_3, because it is is a right triangle, and so it bisects the
hypotenuse.

I think maybe the rotation vectors I'm using are incorrect, or the trigonometry
is off, but I cannot see how.   Hopefully I can do more to understand what is
wrong tonight.


Post a reply to this message

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 09:35:01
Message: <web.53e4d15f3cb258895e7df57c0@news.povray.org>
I've gotten this far - the only thing unknown or in error at this point is the
radius of the sphere.
A nice discussion with good diagrams, in any event.

http://www.verniana.org/volumes/02/HTML/SphericalGeometry.html


Post a reply to this message

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 11:35:01
Message: <web.53e4ed2c3cb258895e7df57c0@news.povray.org>
http://www.answers.com/topic/tetrahedron

"If OABC forms a general tetrahedron with a vertex O as the origin and vectors
a, b and c represent the positions of the vertices A, B, and C with respect to
O, then ... the radius of the circumsphere is given by:

R = |pow(a,2) * |bxc| + pow(b,2) * |cxa| + pow(c,2) |axb| | / 12V
where:
6V = |a.(bxc)|

Circumcenter O = |pow(a,2) * |bxc| + pow(b,2) * |cxa| + pow(c,2) |axb| | / 2a *
(bxc)

If I knew more about Delaunay triangulation or Voronoi cells, this might help me
out:
http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual002.html
"In ℝ3, the vertices of the Voronoi diagram are the circumcenters of the
tetrahedra of the Delaunay tetrahedralization."


Post a reply to this message

From: Le Forgeron
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 12:15:19
Message: <53e4f797$1@news.povray.org>
If I got your problem correctly:
1. you have 4 points: A,B,C,D, not coplanar, and not even aligned by
group of 3. (A,B,C,D define a non-degenerated tetrahedron)
2. you want to find the sphere whose surface includes all the points.

You need additional constraint on D, or the sphere does not exist.

Notice that A,B,C & D are exchangeable. The sphere hold the ABC circle,
but also the ABD, ACD and BCD circles.

The normal going through the centre of all circles meets at the center
of the sphere.

So, one possible solution to check if there is a solution is:
 1. compute the circle for ABC: Center K, normal N.
 2. compute the circle for ABD (or any of the two others): Center L,
normal M.
 3. compute the smallest distance W between (K,K+N) line and (L,L+M) line
 4. if W is not null, there is no intersection, hence no solution.
 5. if W is null, the intersection I is the center of the sphere, and
the radius is IA, IB, IC or ID.


-- 
IQ of crossposters with FU: 100 / (number of groups)
IQ of crossposters without FU: 100 / (1 + number of groups)
IQ of multiposters: 100 / ( (number of groups) * (number of groups))


Post a reply to this message

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 12:50:00
Message: <web.53e4fec23cb258895e7df57c0@news.povray.org>
Just so I can learn some conversion of standard vector math notation, I turned
that all into (Corner_A_1 is already at the origin):

 #declare Vo = Corner_A_1;
 #declare Va = Corner_A_2;
 #declare Vb = Corner_A_3;
 #declare Vc = PointD;

 //  6V = |a.(bxc)|
 #declare V = vdot (Va, vcross (Vb, Vc) ) / 6;
 #debug concat ( "V = ", str (V, 3, 1), "\n")

 //  R = |pow(a,2) * |bxc| + pow(b,2) * |cxa| + pow(c,2) |axb| | / 12V

 #declare CircumRadius = vlength (
  pow(vlength (Va),2) * vcross (Vb, Vc) +
  pow(vlength (Vb),2) * vcross (Vc, Va) +
  pow(vlength (Vc),2) * vcross (Va, Vb)
  ) / (12 * V);
 #debug concat ( "CircumRadius = ", str (CircumRadius, 3, 1), "\n")

 //  O = |pow(a,2) * |bxc| + pow(b,2) * |cxa| + pow(c,2) |axb| | / 2a * (bxc)

 #declare PointO = vlength (
  pow(vlength (Va),2) * vcross (Vb, Vc) +
  pow(vlength (Vb),2) * vcross (Vc, Va) +
  pow(vlength (Vc),2) * vcross (Va, Vb)
  ) / (2 * vlength (Va) * vcross (Vb, Vc) );
 #debug concat("PointO = <", vstr(3, PointO, ", ", 0, 1), "> \n")

V and CircumRadius look plausible, PointO is somewhere under the plane at z =
AlphaCentauri.   :(


Le_Forgeron <jgr### [at] freefr> wrote:
> If I got your problem correctly:
> 1. you have 4 points: A,B,C,D, not coplanar, and not even aligned by
> group of 3. (A,B,C,D define a non-degenerated tetrahedron)
> 2. you want to find the sphere whose surface includes all the points.

Correct.

> You need additional constraint on D, or the sphere does not exist.

Right.  I define H, which is the height above the centroid of the triangle where
D exists.  (Within reason:) When H is small, D sits close to the triangle, and
the sphere is large.  When H gets larger, the radius of the sphere becomes
smaller.

> Notice that A,B,C & D are exchangeable. The sphere hold the ABC circle,
> but also the ABD, ACD and BCD circles.

Correct.

> The normal going through the centre of all circles meets at the center
> of the sphere.

I thought that might be true, but hadn't gotten around to a way of implementing
it.

> So, one possible solution to check if there is a solution is:
>  1. compute the circle for ABC: Center K, normal N.
>  2. compute the circle for ABD (or any of the two others): Center L,
> normal M.
>  3. compute the smallest distance W between (K,K+N) line and (L,L+M) line
>  4. if W is not null, there is no intersection, hence no solution.
>  5. if W is null, the intersection I is the center of the sphere, and
> the radius is IA, IB, IC or ID.

I see that 3 is the key.
I'm fuzzy on exactly how to do that.  I don't mind the exercise - I'm just not
that alert of a reader at the moment...   ;)
Can I define a plane that contains the original triangle's center and PointD and
then use trace along one of the lines to find the intersection?
I'm assuming that there's no "line" object to use for testing an intersection,
and rounding errors might cause a miss anyway....

I'll try the plane and then a tiny cylinder.

Thanks my friend.


Post a reply to this message

From: clipka
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 14:28:29
Message: <53e516cd$1@news.povray.org>
Am 08.08.2014 18:15, schrieb Le_Forgeron:
> If I got your problem correctly:
> 1. you have 4 points: A,B,C,D, not coplanar, and not even aligned by
> group of 3. (A,B,C,D define a non-degenerated tetrahedron)
> 2. you want to find the sphere whose surface includes all the points.
>
> You need additional constraint on D, or the sphere does not exist.

I don't think that's true: Constraint 1. is sufficient.

Every non-degenerate triangle has exactly one circumscribed circle, so 
obviously there exists exactly one circle touching ABC. Let O be that 
circle.

Let N be the rotational axis of O. If D is on N, Let P be an arbitrary 
plane trough N; otherwise, let P be the plane through D and N. Note that 
in either case both D and N are on P.

Note that P intersects O in two points; let these be E and F. Also note 
that D is not on the line EF, otherwise ABCD would be coplanar. Thus, 
DEF is a non-degenerate triangle, and itself has a circumscribed circle. 
Let Q be that circle.

Note that E and F have equal distance to N, thus N runs through the 
center of Q, so rotating Q about N defines a sphere. Let S be that 
sphere. Note that D lies on Q and hence on S; also note that E and F 
both lie on Q, and their rotation about N yields O, thus O lies on S. 
Note that ABC all lie on O, and therefore also on S.

=> ABCD all lie on S.

Finally note that if P if ambiguous, the case is entirely rotationally 
symmetric except for the positions of ABC, and thus S is the same for 
all possible choices of P.

=> S is unambiguous.

=> For any non-degenerate tetrahedron ABCD, there exists exactly one 
circumscribed sphere.


Post a reply to this message

From: Bald Eagle
Subject: Re: Circumscribed sphere
Date: 8 Aug 2014 15:10:00
Message: <web.53e51f643cb258895e7df57c0@news.povray.org>
> I don't think that's true: Constraint 1. is sufficient.

True in general, But the way I define what D _IS_, is that it is the
circumcenter of ABC offest in the normal direction by some distance H.
That way the whole system is parameterized so that for any triangle ABC, I can
vary how much of sphere S "pokes through" circle O.


> Every non-degenerate triangle has exactly one circumscribed circle, so
> obviously there exists exactly one circle touching ABC. Let O be that
> circle.
>
> Let N be the rotational axis of O. If D is on N, Let P be an arbitrary
> plane trough N; otherwise, let P be the plane through D and N. Note that
> in either case both D and N are on P.
>
> Note that P intersects O in two points; let these be E and F. Also note
> that D is not on the line EF, otherwise ABCD would be coplanar. Thus,
> DEF is a non-degenerate triangle, and itself has a circumscribed circle.
> Let Q be that circle.
>
> Note that E and F have equal distance to N, thus N runs through the
> center of Q, so rotating Q about N defines a sphere. Let S be that
> sphere. Note that D lies on Q and hence on S; also note that E and F
> both lie on Q, and their rotation about N yields O, thus O lies on S.
> Note that ABC all lie on O, and therefore also on S.
>
> => ABCD all lie on S.
>
> Finally note that if P if ambiguous, the case is entirely rotationally
> symmetric except for the positions of ABC, and thus S is the same for
> all possible choices of P.
>
> => S is unambiguous.
>
> => For any non-degenerate tetrahedron ABCD, there exists exactly one
> circumscribed sphere.

I did manage to follow all of that after 3 or 4 tries, and you are of course,
correct.   Oh, if only my mind still worked as clearly as yours.

After a few false starts, I got it all to work out and am cleaning up all of the
accumulated dross in the code.

I must say I was rather surprised how little information is readily available
(internet-wise) on practically accomplish this otherwise-simple task.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.