Class: MSPhysics::Spring

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

Overview

Since:

  • 1.0.0

Constant Summary

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_ROTATION_ENABLED =

Since:

  • 1.0.0

false
DEFAULT_MODE =

Since:

  • 1.0.0

0
DEFAULT_ACCEL =

Since:

  • 1.0.0

40.0
DEFAULT_DAMP =

Since:

  • 1.0.0

0.1
DEFAULT_STRENGTH =

Since:

  • 1.0.0

0.8
DEFAULT_SPRING_CONSTANT =

Since:

  • 1.0.0

40.0
DEFAULT_SPRING_DRAG =

Since:

  • 1.0.0

1.0
DEFAULT_START_POSITION =

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, #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) ⇒ Spring

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

Instance Method Details

#accelNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation acceleration factor.

Returns:

  • (Numeric)

    An acceleration factor, a value greater than or equal to zero.

Since:

  • 1.0.0

#accel=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation acceleration factor.

Parameters:

  • value (Numeric)

    An acceleration factor, a value greater than or equal to zero.

Since:

  • 1.0.0

#controllerNumeric

Note:

The actual, desired starting position is, start_position * controller.

Get magnitude and direction of the starting position.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#controller=(value) ⇒ Object

Note:

The actual, desired starting position is, start_position * controller.

Set magnitude and direction of the starting position.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0

#cur_accelerationNumeric

Get current acceleration in meters per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#cur_positionNumeric

Get current position in meters with respect to the starting position.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#cur_velocityNumeric

Get current velocity in meters per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#dampNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation damping coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0

#damp=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation damping coefficient.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0

#limits_enabled=(state) ⇒ Object

Enable/disable min and max position limits.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0

#limits_enabled?Boolean

Determine whether min and max position limits are enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0

#maxNumeric

Get maximum position in meters with respect to the starting position.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#max=(value) ⇒ Object

Set maximum position in meters with respect to the starting position.

Since:

  • 1.0.0

#minNumeric

Get minimum position in meters with respect to the starting position.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#min=(value) ⇒ Object

Set minimum position in meters with respect to the starting position.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0

#modeFixnum

Get mode.

Returns:

  • (Fixnum)
    • 0 - if using spring accel, damp, and strength options.

    • 1 - if using Hooke's spring constant and drag coefficient.

Since:

  • 1.0.0

#mode=(value) ⇒ Object

Set mode.

Parameters:

  • value (Fixnum)
    • 0 - use spring accel, damp, and strength options.

    • 1 - use Hooke's spring constant and drag coefficient options.

Since:

  • 1.0.0

#rotation_enabled=(state) ⇒ Object

Enable/disable rotation along Z-axis of joint.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0

#rotation_enabled?Boolean

Determine whether rotation along Z-axis of joint is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0

#spring_constantNumeric

Note:

This option associates with the Hooke's spring mode.

Get Hooke's spring constant.

Returns:

  • (Numeric)

    A spring constant in kg/s², a value greater than or equal to zero.

Since:

  • 1.0.0

#spring_constant=(value) ⇒ Object

Note:

This option associates with the Hooke's spring mode.

Set Hooke's spring constant.

Parameters:

  • value (Numeric)

    A spring constant in kg/s², a value greater than or equal to zero.

Since:

  • 1.0.0

#spring_dragNumeric

Note:

This option associates with the Hooke's spring mode.

Get Hooke's spring drag.

Returns:

  • (Numeric)

    A spring drag coefficient in kg/s, a value greater than or equal to zero.

Since:

  • 1.0.0

#spring_drag=(value) ⇒ Object

Note:

This option associates with the Hooke's spring mode.

Set Hooke's spring drag.

Parameters:

  • value (Numeric)

    A spring drag coefficient in kg/s, a value greater than or equal to zero.

Since:

  • 1.0.0

#start_positionNumeric

Note:

The actual, desired starting position is, start_position * controller.

Get starting position along joint Z-axis in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0

#start_position=(position) ⇒ Object

Note:

The actual, desired starting position is, start_position * controller.

Set starting position along joint Z-axis in meters.

Parameters:

  • position (Numeric)

Since:

  • 1.0.0

#strengthNumeric

Note:

This option associates with the normal spring mode.

Get spring oscillation strength coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0

#strength=(value) ⇒ Object

Note:

This option associates with the normal spring mode.

Set spring oscillation strength coefficient.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0