Shay’s “Ikebana” CSG Challenge: Cousin Ricky’s Response

This document explains how to use the POV-Ray SDL file callwood-ikebana-csg.inc and describes some of the geometry. [Sample illustration]

Downloaded Files

The zip archive should contain these seven files:

File callwood-ikebana-csg.inc is the only file needed to create the object; the other files are all part of the documentation.

Prerequisite

Requires POV-Ray version 3.5 or later.

Usage

Include this file once prior to using the macro:

#include "callwood-ikebana-csg.inc"

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

Macro CallwoodIkebanaCSG()

Macro CallwoodIkebanaCSG() creates the object, untextured (except as described in the next section). The arguments are:

nPetals
The number of petals
R
The outer radius of curvature of the bowl
Thickness
The thickness of the wall
Edge
An edge size, upon which the minor radii of curvature of rounded edges will be based
arNeck
The angular radius of the space between the necks of two adjacent petals
arPetal
The angular radius of a petal
phiPetal
The angular distance from the bottom of the bowl to the center of a petal
arHole
The angular radius of each hole on the petals
phiHole
The angular distance from the center of a petal to the center of a hole
arCusp
The angular radius of the concave edge of the cusp of a petal; smaller values give a sharper cusp.
thetaCusp
The angle between the meridian of a petal and the curve that forms the cusp; larger values give a taller cusp.

All angles are in degrees.

The sample illustration uses CallwoodIkebanaCSG (8, 110, 3, 1.2, 7, 18.5, 60, 3.6, 6.3, 25, 30).

User-Defined Texture

If CallwoodIkebanaCSG_t_Edge is defined, then it will be used to texture the rounded edges. This is useful for visualizing some of the arguments for CallwoodIkebanaCSG().

Caveats

The Math

The key to CSG fanaticism is insane mathematical perfectionism. The following is for those who are interested in how the model was put together. It is not necessary to understand this in order to use the include file.

Spherical Law of Cosines

This theorem is used extensively to position the various parts of the object.

The spherical law of cosines is: [Spherical triangle]

cos c = cos a cos b + sin a sin b cos C

where a, b, and c are the angular lengths of the sides of a spherical triangle; and C is the angle of the vertex opposite line c.

Solve for c: macro CallwoodIkebanaCSG_SOpposite()

Straightforward inverse cosine.

Solve for a: macro CallwoodIkebanaCSG_SAdjacent()

cos c = ±√(1 − sin2a) cos b + sin a sin b cos C

cos c − sin a sin b cos C = ±√(1 − sin2a) cos b

cos2c + sin2a sin2b cos2C − 2 cos c sin a sin b cos C = (1 − sin2a) cos2b

cos2c + sin2a sin2b cos2C − 2 cos c sin a sin b cos C = cos2b − sin2a cos2b

sin2a sin2b cos2C + sin2a cos2b − 2 cos c sin a sin b cos C + cos2c − cos2b = 0

(sin2b cos2C + cos2b) sin2a − (2 cos c sin b cos C) sin a + (cos2c − cos2b) = 0

Now solve the quadratic equation for sin a, and take an inverse sine.

Solve for C: macro CallwoodIkebanaCSG_SAngle()

cos c − cos a cos b = sin a sin b cos C

(cos c − cos a cos b) ⁄ (sin a sin b) = cos C

cos−1[(cos c − cos a cos b) ⁄ (sin a sin b)] = C

Rounded Edges

The cusps of the petals put a severe constraint on the sizes of the inner and outer rounded edges with respect to each other. This section shows how they were calculated.

My initial impression of Shay’s image was that the edge of the bowl was flat with rounded corners. Closer inspection of the image indicates that there may be only an illusion of flatness. If this is the case, having separate inner and outer rounded edges is overkill. Nevertheless, I am retaining this feature, not only for the sake of freedom of choice, but because I put so much work into it (involving a geometry error and two dead ends) and my ego won’t let it go.

An almost completely round edge may be rendered by passing an Edge argument that is exactly half the size of Thickness. (Calculating the exact Edge value required for a completely round edge will likely make no visual difference.)

[Geometry of the cross section of rounded edges]

R, t, and φ are given.

Derivation of ro:

By the law of sines, ro ⁄ sin φ = (Rro) ⁄ sin 90°

ro ⁄ sin φ = Rro

ro ⁄ sin φ + ro = R

ro + ro sin φ = R sin φ

ro (1 + sin φ) = R sin φ

ro = R sin φ ⁄ (1 + sin φ)

Derivation of ri:

By the law of sines, ri ⁄ sin φ = (Rt + ri) ⁄ sin 90°

ri ⁄ sin φ = Rt + ri

ri ⁄ sin φri = Rt

riri sin φ = (Rt) sin φ

ri (1 − sin φ) = (Rt) sin φ

ri = (Rt) sin φ ⁄ (1 − sin φ)

Derivation of bo:

By the Pythagorean theorem, ro2 + (Rbo)2 = (Rro)2

ro2 + R2 − 2Rbo + bo2 = R2 − 2Rro + ro2

−2Rbo + bo2 = −2Rro

bo2 − 2Rbo + 2Rro = 0

By the quadratic formula, bo = R ± √(R2 − 2Rro)

Rbo = R − [R ± √(R2 − 2Rro)]

Rbo = ±√(R2 − 2Rro); Rbo > 0

Rbo = √(R2 − 2Rro)

bo = R − √(R2 − 2Rro)

Derivation of bi:

Similar triangles: (Rt + bi) ⁄ ri = (Rbo) ⁄ ro

Rt + bi = ri (Rbo) ⁄ ro

bi = ri (Rbo) ⁄ roR + t

Correspondence between the above variables and identifiers in the POV-Ray code
Variable SDL Identifier Comments
R R
t Thickness
R − t rc3_RInner
φ rc3_aMargin Derived from the Edge argument
ro rc3_rOuter_edge
ri rc3_rInner_edge
bo rc3_Outer_depth
bi rc3_Inner_depth

Rims Around the Holes

This feature uses the Pythagorean theorem and the law of cosines. The code should be easy to follow from this diagram.

[Geometry of the cross section of the rim of a hole]

Links

Newsgroup thread | Constructive solid geometry (CSG)

About Callwood-Ikebana-CSG

Copyright © 2013 Richard Callwood III. Some rights reserved.
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.