lib/mittsu/extras/geometries/sphere_geometry.rb in mittsu-0.3.2 vs lib/mittsu/extras/geometries/sphere_geometry.rb in mittsu-0.3.3
- old
+ new
@@ -1,11 +1,11 @@
require 'mittsu/core'
require 'mittsu/math'
module Mittsu
class SphereGeometry < Geometry
- def initialize(radius = 50.0, width_segments = 8, height_segments = 6, phi_start = 0.0, phi_length = (Math::PI * 2.0), theta_start = 0.0, theta_length = Math::PI)
+ def initialize(radius = 50.0, width_segments = 8, height_segments = 6, phi_start = 0.0, phi_length = (::Math::PI * 2.0), theta_start = 0.0, theta_length = ::Math::PI)
super()
@type = 'SphereGeometry'
@parameters = {
@@ -31,12 +31,12 @@
(width_segments + 1).times do |x|
u = x / width_segments.to_f
v = y / height_segments.to_f
vertex = Vector3.new
- vertex.x = -radius * Math.cos(phi_start + u * phi_length) * Math.sin(theta_start + v * theta_length)
- vertex.y = radius * Math.cos(theta_start + v * theta_length)
- vertex.z = radius * Math.sin(phi_start + u * phi_length) * Math.sin(theta_start + v * theta_length)
+ vertex.x = -radius * ::Math.cos(phi_start + u * phi_length) * ::Math.sin(theta_start + v * theta_length)
+ vertex.y = radius * ::Math.cos(theta_start + v * theta_length)
+ vertex.z = radius * ::Math.sin(phi_start + u * phi_length) * ::Math.sin(theta_start + v * theta_length)
@vertices << vertex
vertices_row << @vertices.length - 1.0
uvs_row << Vector2.new(u, 1.0 - v)