Module: ThreeDimensions
- Defined in:
- lib/eymiha_math3.rb
Overview
The ThreeDimensions module adds shorthands for common 3D entities, mostly to improve code readability.
Instance Method Summary collapse
-
#half_pi ⇒ Object
shorthand for pi.
-
#origin ⇒ Object
the origin of 3D space.
-
#pi ⇒ Object
shorthand for pi.
-
#point3(x = 0, y = 0, z = 0) ⇒ Object
shorthand for creating a 3D point in cartesian coordinates.
-
#point3c(c_radius = 0, theta = 0, z = 0) ⇒ Object
shorthand for creating a 3D point in cylindrical coordinates.
-
#point3s(s_radius = 0, theta = 0, phi = 0) ⇒ Object
shorthand for creating a 3D point in spherical coordinates.
-
#quaternion(axis = origin, real = 0) ⇒ Object
shorthand for creating a quaternion.
-
#sqrt2 ⇒ Object
shorthand for the square root of 2.
-
#sqrt3 ⇒ Object
shorthand for the square root of 3.
-
#two_pi ⇒ Object
shorthand for 2*pi.
Instance Method Details
#half_pi ⇒ Object
shorthand for pi.
42 43 44 |
# File 'lib/eymiha_math3.rb', line 42 def half_pi Math::PI/2.0 end |
#origin ⇒ Object
the origin of 3D space.
57 58 59 |
# File 'lib/eymiha_math3.rb', line 57 def origin Point3.origin end |
#point3(x = 0, y = 0, z = 0) ⇒ Object
shorthand for creating a 3D point in cartesian coordinates.
62 63 64 |
# File 'lib/eymiha_math3.rb', line 62 def point3(x=0, y=0, z=0) Point3.new(x,y,z) end |
#point3c(c_radius = 0, theta = 0, z = 0) ⇒ Object
shorthand for creating a 3D point in cylindrical coordinates.
72 73 74 |
# File 'lib/eymiha_math3.rb', line 72 def point3c(c_radius=0, theta=0, z=0) Point3c.new(c_radius,theta,z) end |
#point3s(s_radius = 0, theta = 0, phi = 0) ⇒ Object
shorthand for creating a 3D point in spherical coordinates.
67 68 69 |
# File 'lib/eymiha_math3.rb', line 67 def point3s(s_radius=0, theta=0, phi=0) Point3s.new(s_radius,theta,phi) end |
#quaternion(axis = origin, real = 0) ⇒ Object
shorthand for creating a quaternion.
77 78 79 |
# File 'lib/eymiha_math3.rb', line 77 def quaternion(axis=origin,real=0) Quaternion.new(axis,real) end |
#sqrt2 ⇒ Object
shorthand for the square root of 2.
47 48 49 |
# File 'lib/eymiha_math3.rb', line 47 def sqrt2 Math.sqrt 2 end |
#sqrt3 ⇒ Object
shorthand for the square root of 3.
52 53 54 |
# File 'lib/eymiha_math3.rb', line 52 def sqrt3 Math.sqrt 3 end |
#two_pi ⇒ Object
shorthand for 2*pi.
32 33 34 |
# File 'lib/eymiha_math3.rb', line 32 def two_pi 2.0*Math::PI end |