POV-Ray : Newsgroups : povray.general : Offset surface Server Time
28 Mar 2024 17:10:05 EDT (-0400)
  Offset surface (Message 1 to 10 of 33)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Mike Horvath
Subject: Offset surface
Date: 19 Jul 2018 18:57:53
Message: <5b511771$1@news.povray.org>
Analogous to "parallel curve", but in three dimensions.

https://en.wikipedia.org/wiki/Parallel_curve

What formula could I use to generate an "offset surface" for an 
ellipsoid/spheroid? (An ellipse rotated around a vertical axis.)

Would a parametric function or implicit function be better or faster or 
simpler?

Thanks.


Mike


Post a reply to this message


Attachments:
Download 'cone_of_latitude_oblate_thickness.png' (48 KB)

Preview of image 'cone_of_latitude_oblate_thickness.png'
cone_of_latitude_oblate_thickness.png


 

From: Bald Eagle
Subject: Re: Offset surface
Date: 19 Jul 2018 20:25:01
Message: <web.5b512b1aa78a3750458c7afe0@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> Analogous to "parallel curve", but in three dimensions.
>
> https://en.wikipedia.org/wiki/Parallel_curve
>
> What formula could I use to generate an "offset surface" for an
> ellipsoid/spheroid? (An ellipse rotated around a vertical axis.)
>
> Would a parametric function or implicit function be better or faster or
> simpler?
>
> Thanks.
>
>
> Mike

Since it's symmetric around the origin, just scale it.
If you need a "2D" part of it, just take a slice out of it.

I'm sure you could use a parametric, an isosurface, or possibly even a
polynomial if those are 3D.

As a related aside:
In Shapes2 there's a spheroid, and in Shapes3 there's facetted sphere and ring
sphere, since those might be fun to play with in conjunction with a globe.

http://www.f-lohmueller.de/pov_tut/all_shapes/shapes3_45e.htm


Post a reply to this message

From: Bald Eagle
Subject: Re: Offset surface
Date: 19 Jul 2018 20:30:00
Message: <web.5b512be3a78a3750458c7afe0@news.povray.org>
Also of interest:

http://xahlee.info/SpecialPlaneCurves_dir/Parallel_dir/parallel.html

It's involved with curves, and I just cheated and used trace()   ;)

http://news.povray.org/povray.advanced-users/thread/%3Cweb.592816879146df1fc437ac910%40news.povray.org%3E/


Post a reply to this message

From: Mike Horvath
Subject: Re: Offset surface
Date: 19 Jul 2018 21:01:00
Message: <5b51344c$1@news.povray.org>
On 7/19/2018 8:25 PM, Bald Eagle wrote:
 >
 > Since it's symmetric around the origin, just scale it.
 > If you need a "2D" part of it, just take a slice out of it.

Not sure what you mean. The offset surface of an ellipsoid is definitely 
not another ellipsoid, so simply scaling it won't work.





On 7/19/2018 8:25 PM, Bald Eagle wrote:
> 
> Also of interest:
> 
> http://xahlee.info/SpecialPlaneCurves_dir/Parallel_dir/parallel.html
> 

Interesting. I can't read the formula however. It's been too long since 
took calculus.

:(



> It's involved with curves, and I just cheated and used trace()   ;)
> 
>
http://news.povray.org/povray.advanced-users/thread/%3Cweb.592816879146df1fc437ac910%40news.povray.org%3E/
> 
> 
> 
> 

Do you have any renders of your efforts that you might share?


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: Offset surface
Date: 19 Jul 2018 21:34:43
Message: <5b513c33$1@news.povray.org>
On 7/19/2018 8:25 PM, Bald Eagle wrote:
> 
> Also of interest:
> 
> http://xahlee.info/SpecialPlaneCurves_dir/Parallel_dir/parallel.html
> 

Xah Lee says the parametric formula for an offset curve is

{ xf[t] + d yf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2],
   yf[t] - d xf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2] }

Not sure how to extend that into three dimensions. (I might be able to 
make an SOR using that formula, but I'd rather not.)


Wikipedia says the parametric formula for an ellipsoid is

<math>\begin{align}
x&=a\cos(\theta)\cos(\varphi),\\
y&=b\cos(\theta)\sin(\varphi),\\
z&=c\sin(\theta),\end{align}\,\!</math>

where
<math>
-\frac \pi 2 \le \theta\le \frac \pi 2,
\qquad
-\pi\le \varphi\le \pi.
</math>

Not sure what the derivative of this is. (Calculus was years ago...)


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: Offset surface
Date: 19 Jul 2018 21:50:10
Message: <5b513fd2$1@news.povray.org>
See here:

https://math.stackexchange.com/questions/2857219/formula-for-the-offset-curve-of-an-ellipsoid

Mike



On 7/19/2018 9:36 PM, Mike Horvath wrote:
> On 7/19/2018 8:25 PM, Bald Eagle wrote:
>>
>> Also of interest:
>>
>> http://xahlee.info/SpecialPlaneCurves_dir/Parallel_dir/parallel.html
>>
> 
> Xah Lee says the parametric formula for an offset curve is
> 
> { xf[t] + d yf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2],
>    yf[t] - d xf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2] }
> 
> Not sure how to extend that into three dimensions. (I might be able to 
> make an SOR using that formula, but I'd rather not.)
> 
> 
> Wikipedia says the parametric formula for an ellipsoid is
> 
> <math>\begin{align}
> x&=a\cos(\theta)\cos(\varphi),\\
> y&=b\cos(\theta)\sin(\varphi),\\
> z&=c\sin(\theta),\end{align}\,\!</math>
> 
> where
> <math>
> -\frac \pi 2 \le \theta\le \frac \pi 2,
> \qquad
> -\pi\le \varphi\le \pi.
> </math>
> 
> Not sure what the derivative of this is. (Calculus was years ago...)
> 
> 
> Mike


Post a reply to this message

From: Bald Eagle
Subject: Re: Offset surface
Date: 20 Jul 2018 07:40:00
Message: <web.5b51c9daa78a3750458c7afe0@news.povray.org>
So, I think I started this around 10 last night and [mostly] solved it by
midnight.

I did it in parametric form, but then I couldn't get the stupid parametric to
render, so I somehow was able to see my way to doing it in implicit form for an
isosurface.

We already know the equation for the ellipsoid
https://en.wikipedia.org/wiki/Ellipsoid

In order to derive a normal vector for each point on its surface, we need to
know the equation of the plane tangent to the ellipsoid at those points.

http://www.math.ucla.edu/~ronmiech/Calculus_Problems/32A/chap12/section6/811d45/811_45.html

and that says that the coefficients for the polynomial are the scalars of the
normal vector.

Then ya just plug that into vnormalize to get a unit normal vector and tack that
onto the ellipsoid formula.

Hit the documentation to see what the formulae for vnormalize, vlength, and vdot
are, and you have:


#declare R = 1;
#declare a = 1;
#declare b = 0.7;
#declare c = 1;

#declare F_ellipsoid = function {(pow(x,2)/pow(a,2)) + (pow(y,2)/pow(b,2))
+(pow(z,2)/pow(c,2)) - R}
#declare F_Normal = function {
((pow(x,2)/pow(a,2)) / pow(a,2)) +
((pow(y,2)/pow(b,2)) / pow(b,2)) +
((pow(z,2)/pow(c,2)) / pow(c,2)) }

#declare FVdot = function {pow(((pow(x,2)/pow(a,2)) / pow(a,2)), 2) +
pow(((pow(y,2)/pow(b,2)) / pow(b,2)), 2) + pow(((pow(z,2)/pow(c,2)) / pow(c,2)),
2)}

#declare Normalized = function {F_Normal (x, y, z) / sqrt (FVdot (x, y, z))}


My full scene is here.
Perhaps someone better versed in the parametric object can determine why I can't
get it to render the full surface, since the exact same equations are used in
the nested loop of spheres to correctly approximate the surface.

I think the only additional thing I'd do is find some way to verify the
correctness of this solution by verifying that the distance between the offset
curve and the ellipsoid is constant over the entire surface.
For that, I'd likely use a trace() method for the offset and the ellipsoid, and
then calculate the shortest Euclidean distance.

Might be able to do that and rewrite my trace() based curve making script to
plot out an approximation, and then either use a triangular grid or a series of
rectangles to make a smooth triangle approximation of the surface like Nylander,
Loney, TOK, and Jaap Frank.



########################################################################

#version 3.8;
global_settings {assumed_gamma 1.0}

// Offset / Parallel surface of an ellipsoid.
// Bill Walker "Bald Eagle" 7/20/2018
// for Mike Horvath "posfan12" at
http://news.povray.org/povray.general/thread/%3C5b513fd2%241%40news.povray.org%3E/

// parametric only renders a small section - not functional yet, and SLOW

#include "colors.inc"
//#include "shapes.inc"
//#include "shapes2.inc"
#include "shapes3.inc"

#declare Zoom = 128;
camera {
  orthographic
   location <0, 0, -20>    // position & direction of view
  look_at  <0, 0, 0>
  right x*image_width/Zoom           // horizontal size of view
  up y*image_height/Zoom // vertical size of view
}

camera {
   location <0, 0, -4>    // position & direction of view
  look_at  <0, 0, 0>
  right x*image_width/image_height         // horizontal size of view
  up y // vertical size of view
}

sky_sphere {pigment {rgb <0.5, 0.5, 1>}}
plane {y, -3 pigment {checker}}

light_source {<5, 5, -30> color White}


#declare Ellipse = torus {1, 0.01 rotate x*90 pigment {Red} scale <0.5, 1, 1> }

#declare n=2;
//object {Ellipse}
//object {Ellipse scale <n, n, 1>}




#declare R = 1;
#declare a = 1;
#declare b = 0.7;
#declare c = 1;

#declare F_ellipsoid = function {(pow(x,2)/pow(a,2)) + (pow(y,2)/pow(b,2))
+(pow(z,2)/pow(c,2)) - R}
#declare F_Normal = function {
((pow(x,2)/pow(a,2)) / pow(a,2)) +
((pow(y,2)/pow(b,2)) / pow(b,2)) +
((pow(z,2)/pow(c,2)) / pow(c,2)) }

#declare FVdot = function {pow(((pow(x,2)/pow(a,2)) / pow(a,2)), 2) +
pow(((pow(y,2)/pow(b,2)) / pow(b,2)), 2) + pow(((pow(z,2)/pow(c,2)) / pow(c,2)),
2)}

#declare Normalized = function {F_Normal (x, y, z) / sqrt (FVdot (x, y, z))}

// for dynamic adapting of the max_gradient value
#declare Min_factor = 0.6; // between 0 and 1
#declare MaxGradient = 4;
#declare P0 = MaxGradient*Min_factor;
#declare P1 = sqrt(MaxGradient/(MaxGradient*Min_factor));
#declare P2 = 0.7;  // between  0 and 1

#declare Ellipsoid =
isosurface {
 function {F_ellipsoid (x, y, z)}
 accuracy 0.001
 max_gradient 3
 //evaluate P0, P1, min (P2, 1)
 contained_by {sphere {0, R}}
 //contained_by {box {<-R, -R, -R>, <R, R, R>}}
 pigment {rgb <0, 0, 1>}
}

// for dynamic adapting of the max_gradient value
#declare Min_factor = 0.6; // between 0 and 1
#declare MaxGradient = 3;
#declare P0 = MaxGradient*Min_factor;
#declare P1 = sqrt(MaxGradient/(MaxGradient*Min_factor));
#declare P2 = 0.7;  // between  0 and 1

#declare PEllipsoid =
isosurface {
 function {F_ellipsoid (x, y, z) - Normalized (x, y, z)/5 }
 accuracy 0.001
 max_gradient 5
 //evaluate P0, P1, min (P2, 1)
     contained_by {sphere {0, R*2}}
 //contained_by {box {<-R, -R, -R>*2, <R, R, R>*2}}
 pigment {rgbt <1, 1, 0, 0.8>}
}

object {Ellipsoid}
object {PEllipsoid} // translate x*R*2}


#declare EllipseX = function (u, v) {a*cos(u)*sin(v)}
#declare EllipseY = function (u, v) {b*sin(u)*sin(v)}
#declare EllipseZ = function (v) {c*cos(v)}

#declare FNormalX = function (u, v) {EllipseX (u, v) / pow(a,2)}
#declare FNormalY = function (u, v) {EllipseY (u, v) / pow(b,2)}
#declare FNormalZ = function (v) {EllipseZ (v) / pow(c,2)}

#declare FVDot = function (u, v)
{pow(FNormalX(u,v),2)+pow(FNormalY(u,v),2)+pow(FNormalZ(v),2)}

#declare FVnormalizeX = function (u, v) {FNormalX (u, v) / sqrt (FVDot (u, v))}
#declare FVnormalizeY = function (u, v) {FNormalY (u, v) / sqrt (FVDot (u, v))}
#declare FVnormalizeZ = function (u, v) {FNormalZ (v) / sqrt (FVDot (u, v))}

#declare Step1 = pi/18;
#declare Step2 = pi/36;

/*
#for (V, 0, tau, Step2)
 #for (U, 0, pi, Step1)
  //#declare X = a*cos(U)*sin(V);
  #declare X = EllipseX (U, V);
  //#declare Y = b*sin(U)*sin(V);
  #declare Y = EllipseY (U, V);
  //#declare Z = c*cos(V);
  #declare Z = EllipseZ (V);
  sphere {<X, Y, Z> 0.01 pigment {Blue}}  //point at <x, y, z> on the ellipsoid

  #declare Normal = <X/pow(a,2), Y/pow(b,2), Z/pow(c, 2)>;
  sphere {<EllipseX (U, V) + FVnormalizeX (U, V)/10, EllipseY (U, V) +
FVnormalizeY (U, V)/10, EllipseZ (V) + FVnormalizeZ (U, V)/10> 0.01 pigment
{Red}} // surface normal at <X, Y, Z>
 #end
#end
*/

// --------------------------------------- parametric surface --------------
#declare Parallel = parametric {
 function {EllipseX (u, v)}
 function {EllipseY (u, v)}
 function {EllipseZ (v)}
 <0, pi>, <0, 2*pi>  // start, end (u,v)
 contained_by {sphere {0, R}}
 max_gradient 50
 accuracy 0.005
 precompute 5 x,y,z
 texture {pigment{ color rgb <0, 1, 0>}}
}

//object {Parallel}


Post a reply to this message

From: And
Subject: Re: Offset surface
Date: 20 Jul 2018 10:05:00
Message: <web.5b51eb7aa78a37504dbcf4f0@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> See here:
>
>
https://math.stackexchange.com/questions/2857219/formula-for-the-offset-curve-of-an-ellipsoid
>
> Mike
>
>
>
> On 7/19/2018 9:36 PM, Mike Horvath wrote:
> > On 7/19/2018 8:25 PM, Bald Eagle wrote:
> >>
> >> Also of interest:
> >>
> >> http://xahlee.info/SpecialPlaneCurves_dir/Parallel_dir/parallel.html
> >>
> >
> > Xah Lee says the parametric formula for an offset curve is
> >
> > { xf[t] + d yf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2],
> >    yf[t] - d xf'[t]/Sqrt[xf'[t]^2 + yf'[t]^2] }
> >
> > Not sure how to extend that into three dimensions. (I might be able to
> > make an SOR using that formula, but I'd rather not.)
> >
> >
> > Wikipedia says the parametric formula for an ellipsoid is
> >
> > <math>\begin{align}
> > x&=a\cos(\theta)\cos(\varphi),\\
> > y&=b\cos(\theta)\sin(\varphi),\\
> > z&=c\sin(\theta),\end{align}\,\!</math>
> >
> > where
> > <math>
> > -\frac \pi 2 \le \theta\le \frac \pi 2,
> > \qquad
> > -\pi\le \varphi\le \pi.
> > </math>
> >
> > Not sure what the derivative of this is. (Calculus was years ago...)
> >
> >
> > Mike

Many years ago I ever do something for the same goal.
http://news.povray.org/povray.binaries.images/thread/%3Cweb.5264d1b954cff585cc1fd1150%40news.povray.org%3E/?ttop=423056
&toff=750

But not the same, I used the math formula, not parametric formula. And just suit
for a small offset(a thin shell)
Because it is just an approximation.


Post a reply to this message

From: clipka
Subject: Re: Offset surface
Date: 20 Jul 2018 10:42:06
Message: <5b51f4be$1@news.povray.org>
Am 20.07.2018 um 00:59 schrieb Mike Horvath:
> Analogous to "parallel curve", but in three dimensions.
> 
> https://en.wikipedia.org/wiki/Parallel_curve
> 
> What formula could I use to generate an "offset surface" for an
> ellipsoid/spheroid? (An ellipse rotated around a vertical axis.)
> 
> Would a parametric function or implicit function be better or faster or
> simpler?

You /could/ just pretend that the parallel curve to an ellipsis is also
an ellipsis. AFAIK that's not true, but it could be sufficiently close
for your purposes.

In that case, all you'd have to do would be to scale the ellipsoid.


Post a reply to this message

From: Bald Eagle
Subject: Re: Offset surface
Date: 20 Jul 2018 12:10:00
Message: <web.5b520925a78a3750c437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> You /could/ just pretend that the parallel curve to an ellipsis is also
> an ellipsis. AFAIK that's not true, but it could be sufficiently close
> for your purposes.

I was initially under the impression that he could do this, but they're similar
shapes, and therefore proportional - not constant distance.

I just took a scaled torus and then made a scaled copy - it's definitely not
good.

I'm assuming Mike wants to make an atmosphere for the globe or something
similar.

> In that case, all you'd have to do would be to scale the ellipsoid.
I already suggested this, and was properly shot down.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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