Class: MSPhysics::PointToPoint

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

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_ACCEL =

Since:

  • 1.0.0

40.0
DEFAULT_DAMP =

Since:

  • 1.0.0

0.1
DEFAULT_STRENGTH =

Since:

  • 1.0.0

0.80
DEFAULT_MODE =

Since:

  • 1.0.0

0
DEFAULT_START_DISTANCE =

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

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



20
21
22
23
24
25
26
27
28
29
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 20

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::PointToPoint.create(@address)
  MSPhysics::Newton::PointToPoint.set_accel(@address, DEFAULT_ACCEL)
  MSPhysics::Newton::PointToPoint.set_damp(@address, DEFAULT_DAMP)
  MSPhysics::Newton::PointToPoint.set_strength(@address, DEFAULT_STRENGTH)
  MSPhysics::Newton::PointToPoint.set_mode(@address, DEFAULT_MODE)
  MSPhysics::Newton::PointToPoint.set_start_distance(@address, DEFAULT_START_DISTANCE)
  MSPhysics::Newton::PointToPoint.set_controller(@address, DEFAULT_CONTROLLER)
end

Instance Method Details

#accelNumeric

Get spring oscillation acceleration factor.

Returns:

  • (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



33
34
35
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 33

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

#accel=(value) ⇒ Object

Set spring oscillation acceleration factor.

Parameters:

  • value (Numeric)

    Spring accel, a value greater than or equal to zero.

Since:

  • 1.0.0



40
41
42
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 40

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

#controllerNumeric

Note:

The actual, desired distance is, start_distance * controller.

Get magnitude of the starting distance.

Returns:

  • (Numeric)

Since:

  • 1.0.0



104
105
106
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 104

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

#controller=(value) ⇒ Object

Note:

The actual, desired distance is, start_distance * controller.

Set magnitude of the starting distance.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



112
113
114
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 112

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

#cur_distanceNumeric

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

Returns:

  • (Numeric)

Since:

  • 1.0.0



118
119
120
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 118

def cur_distance
  MSPhysics::Newton::PointToPoint.get_cur_distance(@address)
end

#dampNumeric

Get spring oscillation drag coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



46
47
48
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 46

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

#damp=(value) ⇒ Object

Set spring oscillation drag coefficient.

Parameters:

  • value (Numeric)

    Spring damp, a value between 0.0 and 1.0.

Since:

  • 1.0.0



52
53
54
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 52

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

#modeInteger

Get mode.

Returns:

  • (Integer)
    • 0 - preserve distance.

    • 1 - preserve distance and direction.

Since:

  • 1.0.0



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

def mode
  MSPhysics::Newton::PointToPoint.get_mode(@address)
end

#mode=(value) ⇒ Object

Set mode.

Parameters:

  • value (Integer)
    • 0 - preserve distance.

    • 1 - preserve distance and direction.

Since:

  • 1.0.0



80
81
82
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 80

def mode=(value)
  MSPhysics::Newton::PointToPoint.set_mode(@address, value)
end

#start_distanceNumeric

Note:

The actual, desired distance is, start_distance * controller.

Get starting distance in meters.

Returns:

  • (Numeric)

Since:

  • 1.0.0



88
89
90
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 88

def start_distance
  MSPhysics::Newton::PointToPoint.get_start_distance(@address)
end

#start_distance=(value) ⇒ Object

Note:

The actual, desired distance is, start_distance * controller.

Set starting distance in meters.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



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

def start_distance=(value)
  MSPhysics::Newton::PointToPoint.set_start_distance(@address, value)
end

#strengthNumeric

Get spring strength coefficient.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



58
59
60
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 58

def strength
  MSPhysics::Newton::PointToPoint.get_strength(@address)
end

#strength=(value) ⇒ Object

Set spring strength coefficient.

Parameters:

  • value (Numeric)

    Spring strength, a value between 0.0 and 1.0.

Since:

  • 1.0.0



64
65
66
# File 'RubyExtension/MSPhysics/joint_point_to_point.rb', line 64

def strength=(value)
  MSPhysics::Newton::PointToPoint.set_strength(@address, value)
end