6 #include <gmath/gmath.h>
9 /* distance unit: millimeters
22 /* position in polar coordinates on the parent gear */
23 float pos_dist, pos_angle;
25 GearSlot *conn_slot; /* slot connection */
32 /* position in polar coordinates on the parent gear */
33 float pos_dist_min, pos_dist_max, pos_angle;
35 GearPin *conn_pin; /* pin connection */
42 mutable Mat4 xform, dir_xform, axel_xform;
43 mutable bool xform_valid;
44 void calc_matrix() const;
46 float contour(float u);
50 /* TODO hide most of this shit, especially the stuff which invalidate
51 * the transformation matrices
54 Vec3 pos, axis; // implicitly defines a plane eqn.
55 float pdist; // derived: distance of plane from origin
57 float init_angle; // initial starting angle
58 float angle; // current angle of the gear
60 int nteeth; // number of teeth
62 float radius; // total radius of the gear, including teeth
63 float teeth_length; // how far teeth extend past the radius
64 float thickness; // thickness of the gear along the Z axis
66 float bevel; // bevel size
69 std::vector<Gear*> subgears;
70 std::vector<GearPin> pins;
71 std::vector<GearSlot> slots;
78 Gear *get_super() const;
80 void set_angular_offset(float offs);
81 float get_angular_offset() const;
83 // sets the supplied number of teeth, and calculates the radius
84 // of the gear, to achieve the required tooth pitch
85 void set_teeth(int nt, float tooth_pitch);
86 void set_axis(const Vec3 &axis);
87 const Vec3 &get_axis() const;
88 void set_position(const Vec3 &pos);
89 const Vec3 &get_position() const;
90 Vec3 get_global_position() const; // taking parent gear into account
92 Vec3 get_planar_position() const; // 2D pos of gear on its plane
94 void set_angle(float angle);
95 float get_angle() const;
97 float get_vis_rotation() const;
98 const Mat4 &get_matrix() const;
99 const Mat4 &get_dir_matrix() const;
101 // returns the angle (in radians) from one tooth to the next
102 float get_angular_pitch() const;
105 void draw_wire(float line_width = 1.0f) const;