Skip to content

Instantly share code, notes, and snippets.

@eulersson
Last active February 27, 2017 13:56
Show Gist options
  • Save eulersson/e031d043a45007618abfd25b79089702 to your computer and use it in GitHub Desktop.
Save eulersson/e031d043a45007618abfd25b79089702 to your computer and use it in GitHub Desktop.
Parametric Butterfly Pillow
class ParametricButterflyPillow
{
public:
explicit ParametricButterflyPillow(const double radius) {}
GVector3 evaluate(const double u, const double v) const
{
const double theta = 2.0 * Pi * u;
const double phi = Pi * v;
return GVector3(
cos(theta) * sin(phi),
sin(theta) * cos(phi),
cos(phi)
);
}
GVector3 evaluate_normal(const double u, const double v) const + const double m_radius;
{
GVector3 normal = evaluate(u, v);
return normalize(normal);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment