Class: MSPhysics::CurvyPiston

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

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_ANGULAR_FRICTION =

Since:

  • 1.0.0

0.0
DEFAULT_RATE =

Since:

  • 1.0.0

4.0
DEFAULT_POWER =

Since:

  • 1.0.0

0.0
DEFAULT_ALIGNMENT_POWER =

Since:

  • 1.0.0

0.0
DEFAULT_REDUCTION_RATIO =

Since:

  • 1.0.0

0.1
DEFAULT_CONTROLLER =

Since:

  • 1.0.0

nil
DEFAULT_CONTROLLER_MODE =

Since:

  • 1.0.0

0
DEFAULT_LOOP_ENABLED =

Since:

  • 1.0.0

false
DEFAULT_ALIGNMENT_ENABLED =

Since:

  • 1.0.0

true
DEFAULT_ROTATION_ENABLED =

Since:

  • 1.0.0

true

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) ⇒ CurvyPiston

Create a CurvyPiston 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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 24

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::CurvyPiston.create(@address)
  MSPhysics::Newton::CurvyPiston.set_angular_friction(@address, DEFAULT_ANGULAR_FRICTION)
  MSPhysics::Newton::CurvyPiston.set_rate(@address, DEFAULT_RATE)
  MSPhysics::Newton::CurvyPiston.set_power(@address, DEFAULT_POWER)
  MSPhysics::Newton::CurvyPiston.set_alignment_power(@address, DEFAULT_ALIGNMENT_POWER)
  MSPhysics::Newton::CurvyPiston.set_reduction_ratio(@address, DEFAULT_REDUCTION_RATIO)
  MSPhysics::Newton::CurvyPiston.set_controller(@address, DEFAULT_CONTROLLER)
  MSPhysics::Newton::CurvyPiston.set_controller_mode(@address, DEFAULT_CONTROLLER_MODE)
  MSPhysics::Newton::CurvyPiston.enable_loop(@address, DEFAULT_LOOP_ENABLED)
  MSPhysics::Newton::CurvyPiston.enable_alignment(@address, DEFAULT_ALIGNMENT_ENABLED)
  MSPhysics::Newton::CurvyPiston.enable_rotation(@address, DEFAULT_ROTATION_ENABLED)
end

Instance Method Details

#add_point(position) ⇒ Integer

Append point to the curve.

Parameters:

  • position (Geom::Point3d)

Returns:

  • (Integer)

    point index.

Since:

  • 1.0.0



42
43
44
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 42

def add_point(position)
  MSPhysics::Newton::CurvyPiston.add_point(@address, position)
end

#alignment_enabled=(state) ⇒ Object

Enable/disable alignment to curve.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



253
254
255
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 253

def alignment_enabled=(state)
  MSPhysics::Newton::CurvyPiston.enable_alignment(@address, state)
end

#alignment_enabled?Boolean

Determine whether the connected body is supposed to align with the direction of curve.

Returns:

  • (Boolean)

Since:

  • 1.0.0



247
248
249
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 247

def alignment_enabled?
  MSPhysics::Newton::CurvyPiston.alignment_enabled?(@address)
end

#alignment_powerNumeric

Note:

Has an effect only if alignment is enabled.

Get alignment power.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



260
261
262
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 260

def alignment_power
  MSPhysics::Newton::CurvyPiston.get_alignment_power(@address)
end

#alignment_power=(value) ⇒ Object

Note:

Has an effect only if alignment is enabled.

Set alignment power.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero. Pass zero to use maximum power.

Since:

  • 1.0.0



268
269
270
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 268

def alignment_power=(value)
  MSPhysics::Newton::CurvyPiston.set_alignment_power(@address, value)
end

#angular_frictionNumeric

Get rotational friction.

Returns:

  • (Numeric)

    A numeric value greater than or equal to zero.

Since:

  • 1.0.0



134
135
136
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 134

def angular_friction
  MSPhysics::Newton::CurvyPiston.get_angular_friction(@address)
end

#angular_friction=(value) ⇒ Object

Set rotational friction.

Parameters:

  • value (Numeric)

    A numeric value greater than or equal to zero.

Since:

  • 1.0.0



140
141
142
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 140

def angular_friction=(value)
  MSPhysics::Newton::CurvyPiston.set_angular_friction(@address, value)
end

#clearInteger

Remove all points that make up the curve.

Returns:

  • (Integer)

    The number of points removed.

Since:

  • 1.0.0



67
68
69
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 67

def clear
  MSPhysics::Newton::CurvyPiston.clear_points(@address)
end

#controllerNumeric?

Get curvy piston controller.

Returns:

  • (Numeric, nil)

    Returns one of the following values:

    • Desired position in meters if the controller mode is 0.

    • Magnitude and direction of the linear rate if controller mode is 1.

    • nil if piston is turned off.

Since:

  • 1.0.0



201
202
203
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 201

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

#controller=(value) ⇒ Object

Set curvy piston controller.

Parameters:

  • value (Numeric, nil)

    Accepts one of the following values:

    • Desired position in meters if the controller mode is 0.

    • Magnitude and direction of the linear rate if controller mode is 1.

    • nil to turn off the piston.

Since:

  • 1.0.0



210
211
212
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 210

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

#controller_modeInteger

Get controller mode.

Returns:

  • (Integer)

    Returns one of the following values:

    • 0 to control curvy piston by position.

    • 1 to control curvy piston by speed - strict.

    • 2 to control curvy piston by speed - adaptive.

Since:

  • 1.0.0



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

def controller_mode
  MSPhysics::Newton::CurvyPiston.get_controller_mode(@address)
end

#controller_mode=(mode) ⇒ Object

Set controller mode.

Parameters:

  • mode (Integer)

    Pass one of the following values:

    • 0 to control curvy piston by position.

    • 1 to control curvy piston by speed - strict.

    • 2 to control curvy piston by speed - adaptive.

Since:

  • 1.0.0



228
229
230
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 228

def controller_mode=(mode)
  MSPhysics::Newton::CurvyPiston.set_controller_mode(@address, mode)
end

#cur_accelerationNumeric

Get current acceleration along the curve in meters per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



107
108
109
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 107

def cur_acceleration
  MSPhysics::Newton::CurvyPiston.get_cur_acceleration(@address)
end

#cur_normal_matrixGeom::Transformation?

Get current normal matrix on the curve.

Returns:

  • (Geom::Transformation, nil)

    A transformation in global space or nil if curve is empty or joint is disconnected.

Since:

  • 1.0.0



128
129
130
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 128

def cur_normal_matrix
  MSPhysics::Newton::CurvyPiston.get_cur_normal_matrix(@address)
end

#cur_pointGeom::Point3d?

Get current point on the curve.

Returns:

  • (Geom::Point3d, nil)

    A point in global space or nil if curve is empty or joint is disconnected.

Since:

  • 1.0.0



114
115
116
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 114

def cur_point
  MSPhysics::Newton::CurvyPiston.get_cur_point(@address)
end

#cur_positionNumeric

Get current position along the curve in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



95
96
97
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 95

def cur_position
  MSPhysics::Newton::CurvyPiston.get_cur_position(@address)
end

#cur_vectorGeom::Vector3d?

Get current vector on the curve.

Returns:

  • (Geom::Vector3d, nil)

    A vector in global space or nil if curve is empty or joint is disconnected.

Since:

  • 1.0.0



121
122
123
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 121

def cur_vector
  MSPhysics::Newton::CurvyPiston.get_cur_vector(@address)
end

#cur_velocityNumeric

Get current velocity along the curve in meters per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



101
102
103
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 101

def cur_velocity
  MSPhysics::Newton::CurvyPiston.get_cur_velocity(@address)
end

#get_point_position(index) ⇒ Geom::Point3d?

Get point position by index.

Parameters:

  • index (Integer)

Returns:

  • (Geom::Point3d, nil)

    Point position in global space if the index references an existing point; nil otherwise.

Since:

  • 1.0.0



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

def get_point_position(index)
  MSPhysics::Newton::CurvyPiston.get_point_position(@address, index)
end

#lengthNumeric

Get curve length in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



73
74
75
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 73

def length
  MSPhysics::Newton::CurvyPiston.get_length(@address)
end

#loop_enabled=(state) ⇒ Object

Enable/disable curve looping.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



240
241
242
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 240

def loop_enabled=(state)
  MSPhysics::Newton::CurvyPiston.enable_loop(@address, state)
end

#loop_enabled?Boolean

Determine whether curve looping is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



234
235
236
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 234

def loop_enabled?
  MSPhysics::Newton::CurvyPiston.loop_enabled?(@address)
end

#normal_matricesArray<Geom::Transformation>

Get all normal matrices of the curve.

Returns:

  • (Array<Geom::Transformation>)

    An array of the normal matrices.

Since:

  • 1.0.0



305
306
307
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 305

def normal_matrices
  MSPhysics::Newton::CurvyPiston.get_normal_matrices(@address)
end

#normal_matrix_at_point(point) ⇒ Array<(Geom::Transformation, Numeric)>?

Get normal matrix corresponding to a particular point on or beside the curve.

Parameters:

  • point (Geom::Point3d)

    A point in global space.

Returns:

  • (Array<(Geom::Transformation, Numeric)>, nil)

    A transformation in global space along with overpass value or nil if curve is empty or joint is disconnected.

Since:

  • 1.0.0



299
300
301
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 299

def normal_matrix_at_point(point)
  MSPhysics::Newton::CurvyPiston.get_normal_martix_at_point(@address, point)
end

#normal_matrix_at_position(distance) ⇒ Geom::Transformation?

Get normal matrix corresponding to a particular distance on the curve.

Parameters:

  • distance (Numeric)

    Linear position on curve in meters.

Returns:

  • (Geom::Transformation, nil)

    A transformation in global space or nil if curve is empty or joint is disconnected.

Since:

  • 1.0.0



289
290
291
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 289

def normal_matrix_at_position(distance)
  MSPhysics::Newton::CurvyPiston.get_normal_martix_at_position(@address, distance)
end

#pointsArray<Geom::Point3d>

Get all points the curve is associated of.

Returns:

  • (Array<Geom::Point3d>)

Since:

  • 1.0.0



55
56
57
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 55

def points
  MSPhysics::Newton::CurvyPiston.get_points(@address)
end

#points_sizeInteger

Get the number of points that make up the curve.

Returns:

  • (Integer)

Since:

  • 1.0.0



61
62
63
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 61

def points_size
  MSPhysics::Newton::CurvyPiston.get_points_size(@address)
end

#powerNumeric

Note:

A power value of zero represents maximum power.

Get movement power in Watts.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



159
160
161
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 159

def power
  MSPhysics::Newton::CurvyPiston.get_power(@address)
end

#power=(value) ⇒ Object

Note:

A power value of zero represents maximum power.

Set movement power in Watts.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



166
167
168
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 166

def power=(value)
  MSPhysics::Newton::CurvyPiston.set_power(@address, value)
end

#rateNumeric

Get maximum linear rate in meters per second.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



146
147
148
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 146

def rate
  MSPhysics::Newton::CurvyPiston.get_rate(@address)
end

#rate=(value) ⇒ Object

Set maximum linear rate in meters per second.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



152
153
154
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 152

def rate=(value)
  MSPhysics::Newton::CurvyPiston.set_rate(@address, value)
end

#reduction_ratioNumeric

Note:

Reduction ratio is a feature that reduces linear rate of the joint when its current position nears its desired position. Linear reduction ratio starts acting upon the linear rate of the joint when the difference between the current position and the desired position of the joint is less than rate * reduction_ratio meters.

Note:

A reduction ratio of zero disables the reduction feature.

Note:

A typical reduction ratio value is 0.1.

Get linear reduction ratio.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



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

def reduction_ratio
  MSPhysics::Newton::CurvyPiston.get_reduction_ratio(@address)
end

#reduction_ratio=(value) ⇒ Object

Note:

Reduction ratio is a feature that reduces linear rate of the joint when its current position nears its desired position. Linear reduction ratio starts acting upon the linear rate of the joint when the difference between the current position and the desired position of the joint is less than rate * reduction_ratio meters.

Note:

A reduction ratio of zero disables the reduction feature.

Note:

A typical reduction ratio value is 0.1.

Get linear reduction ratio.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



192
193
194
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 192

def reduction_ratio=(value)
  MSPhysics::Newton::CurvyPiston.set_reduction_ratio(@address, value)
end

#remove_point(index) ⇒ Boolean

Remove point from curve at index.

Parameters:

  • index (Integer)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



49
50
51
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 49

def remove_point(index)
  MSPhysics::Newton::CurvyPiston.remove_point(@address, index)
end

#rotation_enabled=(state) ⇒ Object

Enable/disable rotation along the current point on curve.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



281
282
283
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 281

def rotation_enabled=(state)
  MSPhysics::Newton::CurvyPiston.enable_rotation(@address, state)
end

#rotation_enabled?Boolean

Determine whether the rotation along the current point on curve is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



275
276
277
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 275

def rotation_enabled?
  MSPhysics::Newton::CurvyPiston.rotation_enabled?(@address)
end

#set_point_position(index, position) ⇒ Boolean

Set point position by index.

Parameters:

  • index (Integer)
  • position (Geom::Point3d)

    Point position in global space.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



89
90
91
# File 'RubyExtension/MSPhysics/joint_curvy_piston.rb', line 89

def set_point_position(index, position)
  MSPhysics::Newton::CurvyPiston.set_point_position(@address, index, position)
end