Class: Mittsu::ParametricGeometry
- Defined in:
- lib/mittsu/extras/geometries/parametric_geometry.rb
Instance Attribute Summary
Attributes inherited from Geometry
#bounding_box, #bounding_sphere, #colors, #dynamic, #face_vertex_uvs, #faces, #has_tangents, #id, #line_distances, #morph_colors, #morph_normals, #morph_targets, #name, #skin_indices, #skin_weights, #type, #uuid, #vertices
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(func, slices, stacks) ⇒ ParametricGeometry
constructor
A new instance of ParametricGeometry.
Methods inherited from Geometry
#apply_matrix, #center, #clone, #compute_bounding_box, #compute_bounding_sphere, #compute_face_normals, #compute_line_distances, #compute_morph_normals, #compute_tangents, #compute_vertex_normals, #dispose, #from_buffer_geometry, #merge, #merge_mesh, #merge_vertices, #to_json
Methods included from EventDispatcher
#add_event_listener, #dispatch_event, #has_event_listener, #remove_event_listener
Constructor Details
#initialize(func, slices, stacks) ⇒ ParametricGeometry
Returns a new instance of ParametricGeometry.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mittsu/extras/geometries/parametric_geometry.rb', line 5 def initialize(func, slices, stacks) super() @type = 'ParametricGeometry' @parameters = { func: func, slices: slices, stacks: stacks } from_buffer_geometry(ParametricBufferGeometry.new(func, slices, stacks)) merge_vertices end |
Class Method Details
.klein ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mittsu/extras/geometries/parametric_geometry.rb', line 20 def self.klein -> (v, u, target = Vector3.new) { u *= ::Math::PI v *= 2.0 * ::Math::PI u = u * 2.0 x = nil y = nil z = nil if u < ::Math::PI x = 3.0 * ::Math.cos(u) * (1.0 + ::Math.sin(u)) + (2.0 * (1.0 - ::Math.cos(u) / 2.0)) * ::Math.cos(u) * ::Math.cos(v) z = -8.0 * ::Math.sin(u) - 2.0 * (1.0 - ::Math.cos(u) / 2.0) * ::Math.sin(u) * ::Math.cos(v) else x = 3.0 * ::Math.cos(u) * (1.0 + ::Math.sin(u)) + (2.0 * (1.0 - ::Math.cos(u) / 2.0)) * ::Math.cos(v + ::Math::PI) z = -8.0 * ::Math.sin(u) end y = -2.0 * (1.0 - ::Math.cos(u) / 2.0) * ::Math.sin(v) target.set(x, y, z) } end |
.mobius ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mittsu/extras/geometries/parametric_geometry.rb', line 54 def self.mobius -> (u, t, target = Vector3.new) { # flat mobius strip # http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations- u = u - 0.5 v = 2.0 * ::Math::PI * t a = 2.0 x = ::Math.cos(v) * (a + u * ::Math.cos(v / 2.0)) y = ::Math.sin(v) * (a + u * ::Math.cos(v / 2.0)) z = u * ::Math.sin(v / 2) target.set(x, y, z) } end |
.mobius3d ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mittsu/extras/geometries/parametric_geometry.rb', line 71 def self.mobius3d -> (u, t, target = Vector3.new) { # volumetric mobius strip u *= ::Math::PI t *= 2.0 * ::Math::PI u = u * 2.0 phi = u / 2.0 major = 2.25 a = 0.125 b = 0.65 x = a * ::Math.cos(t) * ::Math.cos(phi) - b * ::Math.sin(t) * ::Math.sin(phi) z = a * ::Math.cos(t) * ::Math.sin(phi) + b * ::Math.sin(t) * ::Math.cos(phi) y = (major + x) * ::Math.sin(u) x = (major + x) * ::Math.cos(u) target.set(x, y, z) } end |