SphereSweep 1.0 User Manual

Abstract

[Demo image] SphereSweep is a library module from the Persistence of Vision Ray Tracer (POV-Ray) Object Collection.

POV-Ray’s sphere_sweep primitive is a useful object, but it is sometimes prone to artifacts and unreliable automatic bounding. This module provides a variety of alternatives that approximate sphere sweeps using blobs or linear segments. Also included is an alternate interface to the actual sphere_sweep object.

The control points and radii are specified in arrays.


Table of Contents


Overview

Downloaded Files

The italicized nnnnnn in some of the file names represents the 6-digit number that is in the name of the .zip file.

Key Files
File Description
spheresweep.html The user manual (this document)
spheresweep.inc The SphereSweep software
spheresweep.jpg Sample output
spheresweep_cockpit.pov Demonstration scene description files
spheresweep_infinity.pov
spheresweep_lanes.pov
READMEnnnnnn.html Important information about using the Object Collection
Other Files
File Description
spheresweep.css A file used by the user manual
spheresweep_blob_field.jpg Illustrations for the user manual
spheresweep_blob_margin.jpg
spheresweep_icon_diff.png
spheresweep_icon_opaque.png
spheresweep_icon_transp.png
spheresweep_thumbnail.jpg
spheresweep_description.txt A brief description of SphereSweep
spheresweep_keywords.txt A list of keywords
spheresweep_prereqs.txt Prerequisites (empty file)
cc-LGPL-a.png Administrative files
Versionnnnnnn.js

Table of contents


Usage

Include this file once prior to using any of the macros:

#include "spheresweep.inc"

Including the file more than once is unnecessary, but harmless.

If any of the object macros other than SphereSweep_Native() are used, POV-Ray will issue a warning that the experimental feature spline is used. This is normal and expected.

Prerequisites

Requires POV-Ray version 3.5 or later.

Namespace Compliance

All file names in this module and all global and local identifiers defined in spheresweep.inc comply fully with the Object Collection naming standards, as revised August 2008 and proposed August 2012. The prefixes for this module are “sswp” and “spheresweep,” including any uppercase and lowercase variants; to avoid conflicts, do not declare identifiers in your scene description file that start with either of these prefixes plus an underscore.

The standard include file shapes.inc is used by spheresweep.inc.

Table of contents


Macros

Macro Arguments

Spline Types

These values may be used as the Type argument:

Not all spline types can be used with all macros. This table gives a summary of availability:

Macro B-Spline Bézier Spline Cubic Spline Linear Spline Natural Spline Quadratic Spline
SphereSweep_Approx no no YES YES YES YES
SphereSweep_Blob_field no no YES YES YES YES
SphereSweep_Blob_margin no no YES YES YES YES
SphereSweep_CSG no no YES YES YES YES
SphereSweep_Merge no no YES YES YES YES
SphereSweep_Native YES no YES YES no no
SphereSweep_Union no no YES YES YES YES

Array of Spline Control Points

The elements of the v_Points array will be converted to 3-D vectors. A flat object can be defined in the x-y plane with an array of 2-D vectors.

Array of Sphere Radii

If the Radii array is shorter than the array of spline control points (v_Points), the last radius will be used for the remainder of the sphere sweep or approximation thereof. This means that you can use an array of one element for a sphere sweep of constant radius.

Table of contents


SphereSweep_Approx (Type, v_Points, Radii, Res, Tolerance)

A sphere_sweep object that uses a linear spline to approximate a sphere sweep of another spline type. Note that for opaque objects that are not in a CSG difference or intersection, SphereSweep_Union() renders much faster with the same results (although with a higher object count).

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of segments between each pair of adjacent spline control points
Tolerance:
The depth tolerance, as described in the sphere_sweep documentation. For the default tolerance, use 0 (zero).

Table of contents


SphereSweep_Blob_field (Type, v_Points, Radii, Res, Field, Use_Sturm)

An approximation of a sphere sweep using a blob of spheres, with a blob field that varies in proportion to the sphere sweep radii.

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of sphere components between each pair of adjacent spline control points
Field:
The blob field radius, in relation to the sphere radii. [Illustration of Field argument] For example, a value of 2 results in a field radius twice the size of each sphere radius.
Use_Sturm:
Boolean; whether or not to use the slower, but more accurate Sturmian root solver.

Table of contents


SphereSweep_Blob_margin (Type, v_Points, Radii, Res, Margin, Use_Sturm)

An approximation of a sphere sweep using a blob of spheres, with a constant blob field margin.

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of sphere components between each pair of adjacent spline control points
Margin:
The blob field beyond the sphere radius. [Illustration of Margin argument] For example, if Margin is 0.5 and a sphere’s radius is 2.0, then the field radius will be 2.5.
Use_Sturm:
Boolean; whether or not to use the slower, but more accurate Sturmian root solver.

Table of contents


SphereSweep_CSG (Type, v_Points, Radii, Res, Use_merge)

An approximation of a sphere sweep using a CSG merge or union of linear segments. Note that for transparent objects, SphereSweep_Approx() renders faster with the same results.

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of segments between each pair of adjacent spline control points
Use_merge:
Whether or not to use a CSG merge. In general, pass yes if the object is to be transparent, no otherwise.

Table of contents


SphereSweep_Merge (Type, v_Points, Radii, Res)

An approximation of a sphere sweep using a CSG merge of linear segments. Although this macro is intended for transparent objects, SphereSweep_Approx() renders these faster with the same results.

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of segments between each pair of adjacent spline control points

Table of contents


SphereSweep_Native (Type, v_Points, Radii, Tolerance)

A wrapper for a regular, bona fide sphere_sweep object. If you’re not having any problems with bounding or artifacts, but do have an array of points and an array of sphere radii, you’re all set.

Arguments

Type:
The spline type. Only those spline types supported natively by POV-Ray’s sphere_sweep primitive can be used (SSWP_B_SPLINE, SSWP_CUBIC_SPLINE, and SSWP_LINEAR_SPLINE).
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Tolerance:
The depth tolerance, as described in the sphere_sweep documentation. For the default tolerance, use 0 (zero).

Table of contents


SphereSweep_Union (Type, v_Points, Radii, Res)

An approximation of a sphere sweep using a CSG union of linear segments. In general, use this for opaque objects.

Arguments

Type:
The spline type
v_Points:
An array of spline control points
Radii:
An array of sphere radii corresponding to the spline control points
Res:
The number of segments between each pair of adjacent spline control points

Table of contents


Utility Macro and Function

Macro SSwp_Subarray (Array, Start, End)

Returns a one-dimensional array that is a copy of a subrange of another one-dimensional array.

Arguments

Array:
The array to be copied
Start:
The index of the first element to be copied
End:
The index of the last element to be copied

Table of contents


Function SSwp_fn_Blob_strength (RSurface, RField)

Returns the field strength that yields a blob component of the desired surface radius. The default blob threshold of 1.0 is assumed.

This function is used internally by macros SphereSweep_Blob_field() and SphereSweep_Blob_margin(), but is too useful not to document. More blob-related functions are available from the Object Collection module RoundEdge.

Arguments

Note: In spheresweep.inc, the function arguments are prefixed with “sswp_Pn_” in order to avoid a POV-Ray namespace scope feature. These prefixes are omitted here for clarity.

RSurface:
The desired surface radius of the blob component
RField:
The field radius of the component

Table of contents


Other Identifiers

Identifier Type Description Value
SPHERESWEEP_VERSION float The SphereSweep version, in case the caller needs to know. 1.0

Internal Identifiers

Any identifiers in spheresweep.inc that are not documented in this manual are considered “private” or “protected,” and are subject to change or elimination in a future update.

Table of contents


Observations

Artifacts

Render Speed

These observations are not hard and fast rules.

Table of contents


About SphereSweep

Copyright © 2013 Richard Callwood III. Some rights reserved. Licensed under the Creative Commons-GNU Lesser General Public License.

Change Log

Version Date Notes
1.0 July 22, 2013
  • Software is created.

Table of contents