POV-Ray : Newsgroups : povray.binaries.images : Circumscribed sphere : Re: Circumscribed sphere Server Time
3 May 2024 01:53:22 EDT (-0400)
  Re: Circumscribed sphere  
From: Bald Eagle
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

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