Class: MSPhysics::Slider

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

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_MIN =

Since:

  • 1.0.0

-10.0
DEFAULT_MAX =

Since:

  • 1.0.0

10.0
DEFAULT_LIMITS_ENABLED =

Since:

  • 1.0.0

false
DEFAULT_FRICTION =

Since:

  • 1.0.0

0.0
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) ⇒ Slider

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



19
20
21
22
23
24
25
26
27
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 19

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::Slider.create(@address)
  MSPhysics::Newton::Slider.set_min(@address, DEFAULT_MIN)
  MSPhysics::Newton::Slider.set_max(@address, DEFAULT_MAX)
  MSPhysics::Newton::Slider.enable_limits(@address, DEFAULT_LIMITS_ENABLED)
  MSPhysics::Newton::Slider.set_friction(@address, DEFAULT_FRICTION)
  MSPhysics::Newton::Slider.set_controller(@address, DEFAULT_CONTROLLER)
end

Instance Method Details

#controllerNumeric

Get slider controller, the magnitude of the linear friction.

Returns:

  • (Numeric)

Since:

  • 1.0.0



96
97
98
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 96

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

#controller=(value) ⇒ Object

Set slider controller, the magnitude of the linear friction.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



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

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

#cur_accelerationNumeric

Get current acceleration in meters per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

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

#cur_positionNumeric

Get current position in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



31
32
33
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 31

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

#cur_velocityNumeric

Get current velocity in meters per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



37
38
39
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 37

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

#frictionNumeric

Get movement friction.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



84
85
86
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 84

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

#friction=(value) ⇒ Object

Set movement friction.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



90
91
92
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 90

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

#limits_enabled=(state) ⇒ Object

Enable/disable min and max position limits.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



78
79
80
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 78

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

#limits_enabled?Boolean

Determine whether min and max position limits are enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



72
73
74
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 72

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

#maxNumeric

Get maximum position in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

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

#max=(value) ⇒ Object

Set maximum position in meters.

Since:

  • 1.0.0



66
67
68
# File 'RubyExtension/MSPhysics/joint_slider.rb', line 66

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

#minNumeric

Get minimum position in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



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

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

#min=(value) ⇒ Object

Set minimum position in meters.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



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

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