Class: MSPhysics::Hinge

Inherits:
Joint show all
Defined in:
RubyExtension/MSPhysics/joint_hinge.rb

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_MIN =

Since:

  • 1.0.0

-180.0.degrees
DEFAULT_MAX =

Since:

  • 1.0.0

180.0.degrees
DEFAULT_LIMITS_ENABLED =

Since:

  • 1.0.0

false
DEFAULT_MODE =

Since:

  • 1.0.0

0
DEFAULT_FRICTION =

Since:

  • 1.0.0

0.0
DEFAULT_ACCEL =

Since:

  • 1.0.0

40.0
DEFAULT_DAMP =

Since:

  • 1.0.0

0.1
DEFAULT_STRENGTH =

Since:

  • 1.0.0

0.8
DEFAULT_SPRING_CONSTANT =

Since:

  • 1.0.0

40.0
DEFAULT_SPRING_DRAG =

Since:

  • 1.0.0

1.0
DEFAULT_START_ANGLE =

Since:

  • 1.0.0

0.0.degrees
DEFAULT_CONTROLLER =

Since:

  • 1.0.0

1.0

Constants inherited from Joint

Joint::DEFAULT_BODIES_COLLIDABLE, Joint::DEFAULT_BREAKING_FORCE, Joint::DEFAULT_SOLVER_MODEL, Joint::DEFAULT_STIFFNESS

Instance Method Summary collapse

Methods inherited from Joint

#address, all_joints, #bodies_collidable=, #bodies_collidable?, #breaking_force, #breaking_force=, #child, #connect, #connected?, #destroy, #disconnect, #dof, #get_pin_matrix, #get_pin_matrix2, #get_tension1, #get_tension2, #group, joint_by_address, #name, #name=, #parent, #set_pin_matrix, #solver_model, #solver_model=, #stiffness, #stiffness=, #type, #valid?, validate, #world

Methods inherited from Entity

#inspect, #to_s

Constructor Details

#initialize(world, parent, pin_tra, group = nil) ⇒ Hinge

Create a hinge joint.

Parameters:

  • world (MSPhysics::World)
  • parent (MSPhysics::Body, nil)
  • pin_tra (Geom::Transformation, Array<Numeric>)

    Pin transformation in global space. Matrix origin is interpreted as the pin position. Matrix Z-axis is interpreted as the pin direction.

  • group (Sketchup::Group, Sketchup::ComponentInstance, nil) (defaults to: nil)

Since:

  • 1.0.0



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 26

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::Hinge.create(@address)
  MSPhysics::Newton::Hinge.set_min(@address, DEFAULT_MIN)
  MSPhysics::Newton::Hinge.set_max(@address, DEFAULT_MAX)
  MSPhysics::Newton::Hinge.enable_limits(@address, DEFAULT_LIMITS_ENABLED)
  MSPhysics::Newton::Hinge.set_mode(@address, DEFAULT_MODE)
  MSPhysics::Newton::Hinge.set_friction(@address, DEFAULT_FRICTION)
  MSPhysics::Newton::Hinge.set_accel(@address, DEFAULT_ACCEL)
  MSPhysics::Newton::Hinge.set_damp(@address, DEFAULT_DAMP)
  MSPhysics::Newton::Hinge.set_strength(@address, DEFAULT_STRENGTH)
  MSPhysics::Newton::Hinge.set_spring_constant(@address, DEFAULT_SPRING_CONSTANT)
  MSPhysics::Newton::Hinge.set_spring_drag(@address, DEFAULT_SPRING_DRAG)
  MSPhysics::Newton::Hinge.set_start_angle(@address, DEFAULT_START_ANGLE)
  MSPhysics::Newton::Hinge.set_controller(@address, DEFAULT_CONTROLLER)
end

Instance Method Details

#accelNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation acceleration factor.

Returns:

  • (Numeric)

    An acceleration factor, a value greater than or equal to zero.

Since:

  • 1.0.0



135
136
137
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 135

def accel
  MSPhysics::Newton::Hinge.get_accel(@address)
end

#accel=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation acceleration factor.

Parameters:

  • value (Numeric)

    An acceleration factor, a value greater than or equal to zero.

Since:

  • 1.0.0



143
144
145
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 143

def accel=(value)
  MSPhysics::Newton::Hinge.set_accel(@address, value)
end

#controllerNumeric

Get hinge controller, the magnitude of the rotational friction or the magnitude and direction of the starting angle, depending on the mode.

Returns:

  • (Numeric)

Since:

  • 1.0.0



226
227
228
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 226

def controller
  MSPhysics::Newton::Hinge.get_controller(@address)
end

#controller=(value) ⇒ Object

Set hinge controller, the magnitude of the rotational friction or the magnitude and direction of the starting angle, depending on the mode.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



233
234
235
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 233

def controller=(value)
  MSPhysics::Newton::Hinge.set_controller(@address, value)
end

#cur_alphaNumeric

Get current angular acceleration in radians per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



57
58
59
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 57

def cur_alpha
  MSPhysics::Newton::Hinge.get_cur_alpha(@address)
end

#cur_angleNumeric

Get current angle in radians with respect to the starting angle.

Returns:

  • (Numeric)

Since:

  • 1.0.0



45
46
47
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 45

def cur_angle
  MSPhysics::Newton::Hinge.get_cur_angle(@address)
end

#cur_omegaNumeric

Get current angular velocity in radians per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



51
52
53
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 51

def cur_omega
  MSPhysics::Newton::Hinge.get_cur_omega(@address)
end

#dampNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation damping coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



150
151
152
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 150

def damp
  MSPhysics::Newton::Hinge.get_damp(@address)
end

#damp=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation damping coefficient.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



157
158
159
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 157

def damp=(value)
  MSPhysics::Newton::Hinge.set_damp(@address, value)
end

#frictionNumeric

Note:

This option associates with friction mode.

Note:

The actual friction is friction * controller.

Get rotational friction.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



119
120
121
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 119

def friction
  MSPhysics::Newton::Hinge.get_friction(@address)
end

#friction=(value) ⇒ Object

Note:

This option associates with friction mode.

Note:

The actual friction is friction * controller.

Set rotational friction.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



127
128
129
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 127

def friction=(value)
  MSPhysics::Newton::Hinge.set_friction(@address, value)
end

#limits_enabled=(state) ⇒ Object

Enable/disable min & max angle limits.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



93
94
95
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 93

def limits_enabled=(state)
  MSPhysics::Newton::Hinge.enable_limits(@address, state)
end

#limits_enabled?Boolean

Determine whether min & max angle limits are enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



87
88
89
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 87

def limits_enabled?
  MSPhysics::Newton::Hinge.limits_enabled?(@address)
end

#maxNumeric

Get maximum angle in radians with respect to the starting angle.

Returns:

  • (Numeric)

Since:

  • 1.0.0



75
76
77
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 75

def max
  MSPhysics::Newton::Hinge.get_max(@address)
end

#max=(value) ⇒ Object

Set maximum angle in radians with respect to the starting angle.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



81
82
83
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 81

def max=(value)
  MSPhysics::Newton::Hinge.set_max(@address, value)
end

#minNumeric

Get minimum angle in radians with respect to the starting angle.

Returns:

  • (Numeric)

Since:

  • 1.0.0



63
64
65
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 63

def min
  MSPhysics::Newton::Hinge.get_min(@address)
end

#min=(value) ⇒ Object

Set minimum angle in radians with respect to the starting angle.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



69
70
71
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 69

def min=(value)
  MSPhysics::Newton::Hinge.set_min(@address, value)
end

#modeInteger

Get mode.

Returns:

  • (Integer)
    • 0 - if using friction option

    • 1 - if using spring accel, damp, and strength options.

    • 2 - if using Hooke’s spring constant and drag coefficient.

Since:

  • 1.0.0



102
103
104
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 102

def mode
  MSPhysics::Newton::Hinge.get_mode(@address)
end

#mode=(value) ⇒ Object

Set mode.

Parameters:

  • value (Integer)
    • 0 - use friction option

    • 1 - use spring accel, damp, and strength options.

    • 2 - use Hooke’s spring constant and drag coefficient options.

Since:

  • 1.0.0



111
112
113
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 111

def mode=(value)
  MSPhysics::Newton::Hinge.set_mode(@address, value)
end

#spring_constantNumeric

Note:

This option associates with the Hooke’s spring mode.

Get Hooke’s spring constant.

Returns:

  • (Numeric)

    A spring constant in kg/s², a value greater than or equal to zero.

Since:

  • 1.0.0



179
180
181
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 179

def spring_constant
  MSPhysics::Newton::Hinge.get_spring_constant(@address)
end

#spring_constant=(value) ⇒ Object

Note:

This option associates with the Hooke’s spring mode.

Set Hooke’s spring constant.

Parameters:

  • value (Numeric)

    A spring constant in kg/s², a value greater than or equal to zero.

Since:

  • 1.0.0



187
188
189
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 187

def spring_constant=(value)
  MSPhysics::Newton::Hinge.set_spring_constant(@address, value)
end

#spring_dragNumeric

Note:

This option associates with the Hooke’s spring mode.

Get Hooke’s spring drag.

Returns:

  • (Numeric)

    A spring drag coefficient in kg/s, a value greater than or equal to zero.

Since:

  • 1.0.0



195
196
197
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 195

def spring_drag
  MSPhysics::Newton::Hinge.get_spring_drag(@address)
end

#spring_drag=(value) ⇒ Object

Note:

This option associates with the Hooke’s spring mode.

Set Hooke’s spring drag.

Parameters:

  • value (Numeric)

    A spring drag coefficient in kg/s, a value greater than or equal to zero.

Since:

  • 1.0.0



203
204
205
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 203

def spring_drag=(value)
  MSPhysics::Newton::Hinge.set_spring_drag(@address, value)
end

#start_angleNumeric

Note:

This associates with the spring modes only.

Note:

The actual starting angle is, start_angle * controller.

Get starting angle in radians.

Returns:

  • (Numeric)

Since:

  • 1.0.0



211
212
213
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 211

def start_angle
  MSPhysics::Newton::Hinge.get_start_angle(@address)
end

#start_angle=(angle) ⇒ Object

Note:

This associates with the spring modes only.

Note:

The actual starting angle is, start_angle * controller.

Set starting angle in radians.

Parameters:

  • angle (Numeric)

Since:

  • 1.0.0



219
220
221
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 219

def start_angle=(angle)
  MSPhysics::Newton::Hinge.set_start_angle(@address, angle)
end

#strengthNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation strength coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



164
165
166
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 164

def strength
  MSPhysics::Newton::Hinge.get_strength(@address)
end

#strength=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation strength coefficient.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



171
172
173
# File 'RubyExtension/MSPhysics/joint_hinge.rb', line 171

def strength=(value)
  MSPhysics::Newton::Hinge.set_strength(@address, value)
end