POV-Ray : Newsgroups : povray.object-collection : SphereSweep 1.2, with Bezier splines : SphereSweep 1.2, with Bezier splines Server Time
30 Nov 2021 22:50:28 EST (-0500)
  SphereSweep 1.2, with Bezier splines  
From: Cousin Ricky
Date: 11 Sep 2015 20:21:40
Message: <55f37014@news.povray.org>
In SphereSweep 1.2, the Bézier spline is implemented for all the object 
macros except SphereSweep_Native().

http://lib.povray.org/searchcollection/index2.php?objectName=SphereSweep&contributorTag=Cousin%20Ricky

In light of recent interest in Bézier sphere sweeps, here are some notes 
on the implementation in spheresweep.inc.

The new include file is nearly twice the size of the previous version. 
The actual Bézier calculation is done in macro SSwp__Bezier_calc(), and 
is remarkably simple.  But, as I have mentioned before, integrating this 
calculation into functional objects was not straightforward.  The bulk 
of the new code is for managing the different segments.  Unlike the 
curve sections of all the other spline types, Bézier segments are not 
logically tied to each other.  This necessitated handling Bézier objects 
separately from all the others, as well as writing new macros dedicated 
to negotiating the splicing of curve segments when and only when the 
segments are physically contiguous.

My calculation uses brute force rather than the single reduced formula 
with all the pow() calls.  This was because my ability to concentrate is 
so bad nowadays that I just gave up on trying to figure it out.  I 
figured that the internal math of the reduced formula would be more 
complicated anyway.  Had I known how simple the final formula was, and 
recalled Clipka's observation that the complexity of the SDL always 
trumps the math, I would have taken that route.  However, the parse time 
is so short, there would be little difference either way.

If you examine the SDL code, you will notice that all of the local 
variables are prefixed with sswp_.  This would seem redundant with the 
#local directives, and makes the code rather hard to follow.  The reason 
for this policy is to circumvent an unfortunate POV-Ray namespace scope 
leakage; it is a requirement for Object Collection compliance level 3. 
(Not all "compliant" modules follow this rule, because it wasn't 
instituted until the scope leakage was discovered, which was well after 
the creation of the Object Collection.)

I've recently discovered that the PointArrays module has Bézier sphere 
sweep capability.  Previously, I had only noticed the lathe and prism 
features.  With all the talk about sphere sweeps lately, I'm surprised 
that Matthew (a.k.a. Blue Herring) never chimed in.  (Are you still 
around, Matthew?)  There is considerable overlap between the two 
modules, including variable radius capability.  Matthew seems to have 
approached the problems similarly to the way I did, although we use 
different user interfaces.  (And, you can check out the SDL for both 
modules, to see how straightforward it was to accommodate varying 
radii.)  I have focused more on sphere sweeps, and have provided more 
options for these than PointArrays does.  PointArrays, for its part, has 
more array manipulation capability.


Post a reply to this message

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