+void Gear::set_teeth(int nt, float tooth_pitch)
+{
+ float circ = tooth_pitch * nt;
+ radius = circ / (2.0 * M_PI);
+ nteeth = nt;
+ init_angle = get_angular_pitch() * 3.0 / 8.0;
+}
+
+void Gear::set_axis(const Vec3 &axis)
+{
+ this->axis = normalize(axis);
+ xform_valid = false;
+}
+
+void Gear::set_position(const Vec3 &pos)
+{
+ this->pos = pos;
+ xform_valid = false;
+}
+
+const Vec3 &Gear::get_position() const
+{
+ return pos;
+}
+
+Vec3 Gear::get_global_position() const
+{
+ return pos; // TODO
+}
+
+void Gear::set_angle(float angle)
+{
+ this->angle = angle;
+ xform_valid = false;
+}
+
+float Gear::get_angle() const
+{
+ return angle;
+}
+
+float Gear::get_vis_rotation() const
+{
+ return fmod(init_angle + angle, M_PI * 2.0);
+}
+
+const Mat4 &Gear::get_matrix() const
+{
+ if(!xform_valid) {
+ calc_matrix();
+ xform_valid = true;
+ }
+ return xform;
+}
+
+const Mat4 &Gear::get_dir_matrix() const
+{
+ if(!xform_valid) {
+ calc_matrix();
+ xform_valid = true;
+ }
+ return xform;
+}
+
+float Gear::get_angular_pitch() const
+{
+ return 2.0 * M_PI / (float)nteeth;
+}
+