Class: MSPhysics::Motor

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

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_ACCEL =

Since:

  • 1.0.0

1.0
DEFAULT_DAMP =

Since:

  • 1.0.0

0.5
DEFAULT_FREE_ROTATE_ENABLED =

Since:

  • 1.0.0

false
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) ⇒ Motor

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



18
19
20
21
22
23
24
25
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 18

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::Motor.create(@address)
  MSPhysics::Newton::Motor.set_accel(@address, DEFAULT_ACCEL)
  MSPhysics::Newton::Motor.set_damp(@address, DEFAULT_DAMP)
  MSPhysics::Newton::Motor.enable_free_rotate(@address, DEFAULT_FREE_ROTATE_ENABLED)
  MSPhysics::Newton::Motor.set_controller(@address, DEFAULT_CONTROLLER)
end

Instance Method Details

#accelNumeric

Note:

The actual acceleration is accel * controller.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Get rotational acceleration in radians per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



50
51
52
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 50

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

#accel=(value) ⇒ Object

Note:

The actual acceleration is accel * controller.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Set rotational acceleration in radians per second per second.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



59
60
61
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 59

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

#controllerNumeric

Note:

The actual acceleration is accel * controller.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Get motor controller, magnitude and direction of the desired acceleration.

Returns:

  • (Numeric)

Since:

  • 1.0.0



100
101
102
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 100

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

#controller=(value) ⇒ Object

Note:

The actual acceleration is accel * controller.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Set motor controller, magnitude and direction of the desired acceleration.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



109
110
111
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 109

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

#cur_alphaNumeric

Get current angular acceleration in radians per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



41
42
43
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 41

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

#cur_angleNumeric

Get current angle in radians.

Returns:

  • (Numeric)

Since:

  • 1.0.0



29
30
31
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 29

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

#cur_omegaNumeric

Get current angular velocity in radians per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



35
36
37
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 35

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

#dampNumeric

Note:

Higher damper makes rotation stronger.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Get rotational damper.

Returns:

  • (Numeric)

Since:

  • 1.0.0



68
69
70
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 68

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

#damp=(value) ⇒ Object

Note:

Higher damper makes rotation stronger.

Note:

The maximum angular rate in radians per second is accel * controller / damp.

Set rotational damper.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



77
78
79
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 77

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

#free_rotate_enabled=(state) ⇒ Object

Enable/disable free rotate. Free rotate allows the motor to spin freely when accel is zero.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



91
92
93
# File 'RubyExtension/MSPhysics/joint_motor.rb', line 91

def free_rotate_enabled=(state)
  MSPhysics::Newton::Motor.enable_free_rotate(@address, state)
end

#free_rotate_enabled?Boolean

Determine whether free rotate is enabled. Free rotate allows the motor to spin freely when accel is zero.

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

def free_rotate_enabled?
  MSPhysics::Newton::Motor.is_free_rotate_enabled?(@address)
end