Class: MSPhysics::CurvySlider

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

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_LINEAR_FRICTION =

Since:

  • 1.0.0

0.0
DEFAULT_ANGULAR_FRICTION =

Since:

  • 1.0.0

0.0
DEFAULT_ALIGNMENT_POWER =

Since:

  • 1.0.0

0.0
DEFAULT_CONTROLLER =

Since:

  • 1.0.0

1.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) ⇒ CurvySlider

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



21
22
23
24
25
26
27
28
29
30
31
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 21

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::CurvySlider.create(@address)
  MSPhysics::Newton::CurvySlider.set_linear_friction(@address, DEFAULT_LINEAR_FRICTION)
  MSPhysics::Newton::CurvySlider.set_angular_friction(@address, DEFAULT_ANGULAR_FRICTION)
  MSPhysics::Newton::CurvySlider.set_alignment_power(@address, DEFAULT_ALIGNMENT_POWER)
  MSPhysics::Newton::CurvySlider.set_controller(@address, DEFAULT_CONTROLLER)
  MSPhysics::Newton::CurvySlider.enable_loop(@address, DEFAULT_LOOP_ENABLED)
  MSPhysics::Newton::CurvySlider.enable_alignment(@address, DEFAULT_ALIGNMENT_ENABLED)
  MSPhysics::Newton::CurvySlider.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



36
37
38
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 36

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

#alignment_enabled=(state) ⇒ Object

Enable/disable alignment to curve.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



183
184
185
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 183

def alignment_enabled=(state)
  MSPhysics::Newton::CurvySlider.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



177
178
179
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 177

def alignment_enabled?
  MSPhysics::Newton::CurvySlider.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



190
191
192
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 190

def alignment_power
  MSPhysics::Newton::CurvySlider.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



198
199
200
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 198

def alignment_power=(value)
  MSPhysics::Newton::CurvySlider.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



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

def angular_friction
  MSPhysics::Newton::CurvySlider.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



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

def angular_friction=(value)
  MSPhysics::Newton::CurvySlider.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



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

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

#controllerNumeric

Get magnitude of the linear and angular friction.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

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

#controller=(value) ⇒ Object

Set magnitude of the linear and angular friction.

Parameters:

  • value (Numeric)

    A numeric value greater than or equal to zero.

Since:

  • 1.0.0



158
159
160
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 158

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

#cur_accelerationNumeric

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

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

def cur_acceleration
  MSPhysics::Newton::CurvySlider.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



122
123
124
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 122

def cur_normal_matrix
  MSPhysics::Newton::CurvySlider.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



108
109
110
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 108

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

#cur_positionNumeric

Get current position along the curve in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

def cur_position
  MSPhysics::Newton::CurvySlider.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



115
116
117
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 115

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

#cur_velocityNumeric

Get current velocity along the curve in meters per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

def cur_velocity
  MSPhysics::Newton::CurvySlider.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



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

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

#lengthNumeric

Get curve length in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

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

#linear_frictionNumeric

Get movement friction.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



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

def linear_friction
  MSPhysics::Newton::CurvySlider.get_linear_friction(@address)
end

#linear_friction=(value) ⇒ Object

Set movement friction.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



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

def linear_friction=(value)
  MSPhysics::Newton::CurvySlider.set_linear_friction(@address, value)
end

#loop_enabled=(state) ⇒ Object

Enable/disable curve looping.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



170
171
172
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 170

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

#loop_enabled?Boolean

Determine whether curve looping is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

def loop_enabled?
  MSPhysics::Newton::CurvySlider.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



235
236
237
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 235

def normal_matrices
  MSPhysics::Newton::CurvySlider.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



229
230
231
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 229

def normal_matrix_at_point(point)
  MSPhysics::Newton::CurvySlider.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



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

def normal_matrix_at_position(distance)
  MSPhysics::Newton::CurvySlider.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



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

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

#points_sizeInteger

Get the number of points that make up the curve.

Returns:

  • (Integer)

Since:

  • 1.0.0



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

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

#remove_point(index) ⇒ Boolean

Remove point from curve at index.

Parameters:

  • index (Integer)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



43
44
45
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 43

def remove_point(index)
  MSPhysics::Newton::CurvySlider.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



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

def rotation_enabled=(state)
  MSPhysics::Newton::CurvySlider.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



205
206
207
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 205

def rotation_enabled?
  MSPhysics::Newton::CurvySlider.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



83
84
85
# File 'RubyExtension/MSPhysics/joint_curvy_slider.rb', line 83

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