Avara3D 0.2.0
C++ API reference
Spring.h
1//
2// Spring.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_SPRING_H
10#define AVARA3D_MESH_PRIMITIVE_SPRING_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18 class Mesh;
19 class Material;
20
29 class Spring : public MeshElement {
30
31 public:
32 // [Public Static Member Functions]
33
35 static std::shared_ptr<Mesh> Mesh(float minorRadius,
36 float majorRadius,
37 float length,
38 unsigned slices = DEFAULT_SLICES,
39 unsigned segments = DEFAULT_SEGMENTS,
40 std::shared_ptr<Material> material = nullptr);
41
42 // [Public Lifecycle Functions]
43
46 float majorRadius,
47 float length,
48 unsigned slices = DEFAULT_SLICES,
49 unsigned segments = DEFAULT_SEGMENTS);
50
51 // [Public Member Functions]
52
54 float minorRadius() const;
55
57 float majorRadius() const;
58
60 float length() const;
61
63 unsigned slices() const;
64
66 unsigned segments() const;
67
68 private:
69 // [Private Constants]
70
71 static constexpr unsigned DEFAULT_SLICES = 8;
72 static constexpr unsigned DEFAULT_SEGMENTS = 32;
73
74 // [Private Member Variables]
75
76 float _minorRadius;
77 float _majorRadius;
78 float _length;
79 unsigned _slices;
80 unsigned _segments;
81 };
82
83}
84
85#endif // AVARA3D_MESH_PRIMITIVE_SPRING_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Helical spring mesh element aligned along the Z axis.
Definition: Spring.h:29
static std::shared_ptr< Mesh > Mesh(float minorRadius, float majorRadius, float length, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a Spring and optional material.
float majorRadius() const
Returns the configured radius from the Z axis to the tube centerline.
unsigned slices() const
Returns the tube cross-section subdivision count.
Spring(float minorRadius, float majorRadius, float length, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS)
Generates spring geometry with the supplied dimensions and subdivisions.
float length() const
Returns the configured axial length.
float minorRadius() const
Returns the configured spring-tube radius.
unsigned segments() const
Returns the helical-path subdivision count.