v0.3.0 API Reference
TorusKnot.h
1//
2// TorusKnot.h
3// avara3d
4//
5// Created by Morgan Davis on 3/6/24.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_TORUSKNOT_H
10#define AVARA3D_MESH_PRIMITIVE_TORUSKNOT_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18class Mesh;
19class Material;
20
26class TorusKnot : public MeshElement {
27
28public:
29 // [Public Static Member Functions]
30
32 static std::shared_ptr<Mesh> Mesh(unsigned p,
33 unsigned q,
34 unsigned slices = DEFAULT_SLICES,
35 unsigned segments = DEFAULT_SEGMENTS,
36 std::shared_ptr<Material> material = nullptr);
37
38 // [Public Lifecycle Functions]
39
41 TorusKnot(unsigned p, unsigned q, unsigned slices = DEFAULT_SLICES, unsigned segments = DEFAULT_SEGMENTS);
42
43 // [Public Member Functions]
44
46 unsigned p() const;
47
49 unsigned q() const;
50
52 unsigned slices() const;
53
55 unsigned segments() const;
56
57private:
58 // [Private Constants]
59
60 static constexpr unsigned DEFAULT_SLICES = 8;
61 static constexpr unsigned DEFAULT_SEGMENTS = 96;
62
63 // [Private Member Variables]
64
65 unsigned _p;
66 unsigned _q;
67 unsigned _slices;
68 unsigned _segments;
69};
70
71} // namespace a3d
72
73#endif // AVARA3D_MESH_PRIMITIVE_TORUSKNOT_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Tubular torus-knot mesh element controlled by the knot parameters p and q.
Definition: TorusKnot.h:26
unsigned slices() const
Returns the tube cross-section subdivision count.
unsigned q() const
Returns the configured q knot parameter.
TorusKnot(unsigned p, unsigned q, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS)
Generates torus-knot geometry with the supplied knot parameters and subdivisions.
unsigned segments() const
Returns the knot-path subdivision count.
static std::shared_ptr< Mesh > Mesh(unsigned p, unsigned q, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a TorusKnot and optional material.
unsigned p() const
Returns the configured p knot parameter.