Class: MSPhysics::Spring
- Defined in:
- RubyExtension/MSPhysics/joint_spring.rb
Overview
Constant Summary collapse
- DEFAULT_MIN =
-10.0
- DEFAULT_MAX =
10.0
- DEFAULT_LIMITS_ENABLED =
false
- DEFAULT_ROTATION_ENABLED =
false
- DEFAULT_MODE =
0
- DEFAULT_ACCEL =
40.0
- DEFAULT_DAMP =
0.1
- DEFAULT_STRENGTH =
0.8
- DEFAULT_SPRING_CONSTANT =
40.0
- DEFAULT_SPRING_DRAG =
1.0
- DEFAULT_START_POSITION =
0.0
- DEFAULT_CONTROLLER =
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
-
#accel ⇒ Numeric
Get spring oscillation acceleration factor.
-
#accel=(value) ⇒ Object
Set spring oscillation acceleration factor.
-
#controller ⇒ Numeric
Get magnitude and direction of the starting position.
-
#controller=(value) ⇒ Object
Set magnitude and direction of the starting position.
-
#cur_acceleration ⇒ Numeric
Get current acceleration in meters per second per second.
-
#cur_position ⇒ Numeric
Get current position in meters with respect to the starting position.
-
#cur_velocity ⇒ Numeric
Get current velocity in meters per second.
-
#damp ⇒ Numeric
Get spring oscillation damping coefficient.
-
#damp=(value) ⇒ Object
Set spring oscillation damping coefficient.
-
#initialize(world, parent, pin_tra, group = nil) ⇒ Spring
constructor
Create a spring joint.
-
#limits_enabled=(state) ⇒ Object
Enable/disable min and max position limits.
-
#limits_enabled? ⇒ Boolean
Determine whether min and max position limits are enabled.
-
#max ⇒ Numeric
Get maximum position in meters with respect to the starting position.
-
#max=(value) ⇒ Object
Set maximum position in meters with respect to the starting position.
-
#min ⇒ Numeric
Get minimum position in meters with respect to the starting position.
-
#min=(value) ⇒ Object
Set minimum position in meters with respect to the starting position.
-
#mode ⇒ Integer
Get mode.
-
#mode=(value) ⇒ Object
Set mode.
-
#rotation_enabled=(state) ⇒ Object
Enable/disable rotation along Z-axis of joint.
-
#rotation_enabled? ⇒ Boolean
Determine whether rotation along Z-axis of joint is enabled.
-
#spring_constant ⇒ Numeric
Get Hooke’s spring constant.
-
#spring_constant=(value) ⇒ Object
Set Hooke’s spring constant.
-
#spring_drag ⇒ Numeric
Get Hooke’s spring drag.
-
#spring_drag=(value) ⇒ Object
Set Hooke’s spring drag.
-
#start_position ⇒ Numeric
Get starting position along joint Z-axis in meters.
-
#start_position=(position) ⇒ Object
Set starting position along joint Z-axis in meters.
-
#strength ⇒ Numeric
Get spring oscillation strength coefficient.
-
#strength=(value) ⇒ Object
Set spring oscillation strength coefficient.
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
Constructor Details
#initialize(world, parent, pin_tra, group = nil) ⇒ Spring
Create a spring joint.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 26 def initialize(world, parent, pin_tra, group = nil) super(world, parent, pin_tra, group) MSPhysics::Newton::Spring.create(@address) MSPhysics::Newton::Spring.set_min(@address, DEFAULT_MIN) MSPhysics::Newton::Spring.set_max(@address, DEFAULT_MAX) MSPhysics::Newton::Spring.enable_limits(@address, DEFAULT_LIMITS_ENABLED) MSPhysics::Newton::Spring.enable_rotation(@address, DEFAULT_ROTATION_ENABLED) MSPhysics::Newton::Spring.set_mode(@address, DEFAULT_MODE) MSPhysics::Newton::Spring.set_accel(@address, DEFAULT_ACCEL) MSPhysics::Newton::Spring.set_damp(@address, DEFAULT_DAMP) MSPhysics::Newton::Spring.set_strength(@address, DEFAULT_STRENGTH) MSPhysics::Newton::Spring.set_spring_constant(@address, DEFAULT_SPRING_CONSTANT) MSPhysics::Newton::Spring.set_spring_drag(@address, DEFAULT_SPRING_DRAG) MSPhysics::Newton::Spring.set_start_position(@address, DEFAULT_START_POSITION) MSPhysics::Newton::Spring.set_controller(@address, DEFAULT_CONTROLLER) end |
Instance Method Details
#accel ⇒ Numeric
This option associates with the normal spring mode.
Get spring oscillation acceleration factor.
110 111 112 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 110 def accel MSPhysics::Newton::Spring.get_accel(@address) end |
#accel=(value) ⇒ Object
This option associates with the normal spring mode.
Set spring oscillation acceleration factor.
118 119 120 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 118 def accel=(value) MSPhysics::Newton::Spring.set_accel(@address, value) end |
#controller ⇒ Numeric
The actual, desired starting position is, start_position * controller
.
Get magnitude and direction of the starting position.
202 203 204 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 202 def controller MSPhysics::Newton::Spring.get_controller(@address) end |
#controller=(value) ⇒ Object
The actual, desired starting position is, start_position * controller
.
Set magnitude and direction of the starting position.
210 211 212 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 210 def controller=(value) MSPhysics::Newton::Spring.set_controller(@address, value) end |
#cur_acceleration ⇒ Numeric
Get current acceleration in meters per second per second.
228 229 230 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 228 def cur_acceleration MSPhysics::Newton::Spring.get_cur_acceleration(@address) end |
#cur_position ⇒ Numeric
Get current position in meters with respect to the starting position.
216 217 218 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 216 def cur_position MSPhysics::Newton::Spring.get_cur_position(@address) end |
#cur_velocity ⇒ Numeric
Get current velocity in meters per second.
222 223 224 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 222 def cur_velocity MSPhysics::Newton::Spring.get_cur_velocity(@address) end |
#damp ⇒ Numeric
This option associates with the normal spring mode.
Get spring oscillation damping coefficient.
125 126 127 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 125 def damp MSPhysics::Newton::Spring.get_damp(@address) end |
#damp=(value) ⇒ Object
This option associates with the normal spring mode.
Set spring oscillation damping coefficient.
132 133 134 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 132 def damp=(value) MSPhysics::Newton::Spring.set_damp(@address, value) end |
#limits_enabled=(state) ⇒ Object
Enable/disable min and max position limits.
74 75 76 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 74 def limits_enabled=(state) MSPhysics::Newton::Spring.enable_limits(@address, state) end |
#limits_enabled? ⇒ Boolean
Determine whether min and max position limits are enabled.
68 69 70 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 68 def limits_enabled? MSPhysics::Newton::Spring.limits_enabled?(@address) end |
#max ⇒ Numeric
Get maximum position in meters with respect to the starting position.
57 58 59 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 57 def max MSPhysics::Newton::Spring.get_max(@address) end |
#max=(value) ⇒ Object
Set maximum position in meters with respect to the starting position.
62 63 64 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 62 def max=(value) MSPhysics::Newton::Spring.set_max(@address, value) end |
#min ⇒ Numeric
Get minimum position in meters with respect to the starting position.
45 46 47 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 45 def min MSPhysics::Newton::Spring.get_min(@address) end |
#min=(value) ⇒ Object
Set minimum position in meters with respect to the starting position.
51 52 53 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 51 def min=(value) MSPhysics::Newton::Spring.set_min(@address, value) end |
#mode ⇒ Integer
Get mode.
94 95 96 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 94 def mode MSPhysics::Newton::Spring.get_mode(@address) end |
#mode=(value) ⇒ Object
Set mode.
102 103 104 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 102 def mode=(value) MSPhysics::Newton::Spring.set_mode(@address, value) end |
#rotation_enabled=(state) ⇒ Object
Enable/disable rotation along Z-axis of joint.
86 87 88 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 86 def rotation_enabled=(state) MSPhysics::Newton::Spring.enable_rotation(@address, state) end |
#rotation_enabled? ⇒ Boolean
Determine whether rotation along Z-axis of joint is enabled.
80 81 82 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 80 def rotation_enabled? MSPhysics::Newton::Spring.rotation_enabled?(@address) end |
#spring_constant ⇒ Numeric
This option associates with the Hooke’s spring mode.
Get Hooke’s spring constant.
154 155 156 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 154 def spring_constant MSPhysics::Newton::Spring.get_spring_constant(@address) end |
#spring_constant=(value) ⇒ Object
This option associates with the Hooke’s spring mode.
Set Hooke’s spring constant.
162 163 164 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 162 def spring_constant=(value) MSPhysics::Newton::Spring.set_spring_constant(@address, value) end |
#spring_drag ⇒ Numeric
This option associates with the Hooke’s spring mode.
Get Hooke’s spring drag.
170 171 172 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 170 def spring_drag MSPhysics::Newton::Spring.get_spring_drag(@address) end |
#spring_drag=(value) ⇒ Object
This option associates with the Hooke’s spring mode.
Set Hooke’s spring drag.
178 179 180 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 178 def spring_drag=(value) MSPhysics::Newton::Spring.set_spring_drag(@address, value) end |
#start_position ⇒ Numeric
The actual, desired starting position is, start_position * controller
.
Get starting position along joint Z-axis in meters.
186 187 188 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 186 def start_position MSPhysics::Newton::Spring.get_start_position(@address) end |
#start_position=(position) ⇒ Object
The actual, desired starting position is, start_position * controller
.
Set starting position along joint Z-axis in meters.
194 195 196 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 194 def start_position=(position) MSPhysics::Newton::Spring.set_start_position(@address, position) end |
#strength ⇒ Numeric
This option associates with the normal spring mode.
Get spring oscillation strength coefficient.
139 140 141 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 139 def strength MSPhysics::Newton::Spring.get_strength(@address) end |
#strength=(value) ⇒ Object
This option associates with the normal spring mode.
Set spring oscillation strength coefficient.
146 147 148 |
# File 'RubyExtension/MSPhysics/joint_spring.rb', line 146 def strength=(value) MSPhysics::Newton::Spring.set_strength(@address, value) end |