lib/mittsu/extras/geometries/polyhedron_geometry.rb in mittsu-0.3.2 vs lib/mittsu/extras/geometries/polyhedron_geometry.rb in mittsu-0.3.3
- old
+ new
@@ -76,12 +76,12 @@
def prepare(vector)
vertex = vector.normalize.clone
vertex.index = @vertices.push(vertex).length - 1
# Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.
- u = azimuth(vector) / 2.0 / Math::PI + 0.5
- v = inclination(vector) / Math::PI + 0.5
+ u = azimuth(vector) / 2.0 / ::Math::PI + 0.5
+ v = inclination(vector) / ::Math::PI + 0.5
vertex.uv = Vector2.new(u, 1.0 - v)
vertex
end
@@ -148,21 +148,21 @@
end
end
# Angle around the Y axis, counter-clockwise when looking from above.
def azimuth(vector)
- Math.atan2(vector.z, -vector.x)
+ ::Math.atan2(vector.z, -vector.x)
end
# Angle above the XZ plane.
def inclination(vector)
- Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z))
+ ::Math.atan2(-vector.y, ::Math.sqrt(vector.x * vector.x + vector.z * vector.z))
end
# Texture fixing helper. Spheres have some odd behaviours.
def correct_uv(uv, vector, azimuth)
return Vector2.new(uv.x - 1.0, uv.y) if azimuth < 0
- return Vector2.new(azimuth / 2.0 / Math::PI + 0.5, uv.y) if vector.x.zero? && vector.z.zero?
+ return Vector2.new(azimuth / 2.0 / ::Math::PI + 0.5, uv.y) if vector.x.zero? && vector.z.zero?
uv.clone
end
end
-end
\ No newline at end of file
+end