TorusKnotGeometry
Generated geometry representing a torus knot.
TorusKnotGeometry constructs a mesh for a (p, q) torus knot, a closed curve that winds p times around the torus's axis of rotational symmetry and q times around a circle in its interior. The tube is extruded along this curve using a Frenet-style frame. When p and q are coprime the result is a true knot; otherwise it forms a link of multiple loops.
cpp
auto geometry = vglx::TorusKnotGeometry::Create({
.radius = 1.0f,
.tube = 0.4f,
.tubular_segments = 64,
.radial_segments = 8,
.p = 2,
.q = 3
});
auto material = vglx::PhongMaterial::Create({.color = 0xFF6E00});
my_scene->Add(vglx::Mesh::Create(geometry, material));INFO
Derives from Geometry and inherits all public properties and methods.
Construction
Constructors
TorusKnotGeometry()
Constructs a torus knot geometry.
cpp
TorusKnotGeometry::TorusKnotGeometry(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters that control the shape and tessellation of the torus knot. |
Factories preferred
TorusKnotGeometry::Create() std::shared_ptr<TorusKnotGeometry>
Creates a shared instance of TorusKnotGeometry with default parameters.
cpp
static std::shared_ptr<TorusKnotGeometry> TorusKnotGeometry::Create();TorusKnotGeometry::Create() std::shared_ptr<TorusKnotGeometry>
Creates a shared instance of TorusKnotGeometry with custom parameters.
cpp
static std::shared_ptr<TorusKnotGeometry> TorusKnotGeometry::Create(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters used to generate the torus knot. |
Types
TorusKnotGeometry::Parameters struct
Parameters for constructing a TorusKnotGeometry object.
| Parameter | Description |
|---|---|
| radius float | Radius of the torus the knot is wound around. |
| tube float | Radius of the tube extruded along the curve. |
| tubular_segments unsigned | Segments along the length of the curve. |
| radial_segments unsigned | Segments around the tube cross-section. |
| p unsigned | Number of windings around the axis of rotational symmetry. |
| q unsigned | Number of windings around the interior of the torus. |