examples/gl2.rb
# Create a NxN grid of points on a face of the cube.  Note that this
# will generate (N+1)*(N+1) points.
#
# Each point is projected on the sphere and stored in an array.  Note
# that all these are points on the unit sphere, and so their distance
# to the origin is 1, and so each point can be used as its own normal.
Create a NxN grid of points on a face of the cube.  Note that this
will generate (N+1)*(N+1) points.

Each point is projected on the sphere and stored in an array.  Note
that all these are points on the unit sphere, and so their distance
to the origin is 1, and so each point can be used as its own normal.
Create a NxN grid of points on a face of the cube . Note that this will generate ( N + 1 ) * ( N + 1 ) points . Each point is projected on the sphere and stored in an array . Note that all these are points on the unit sphere and so their distance to the origin is 1 and so each point can be used as its own normal .
def grid(face, n)
    dx = 2.0/n
    dy = 2.0/n
    a = Array.new
    n += 1
    n.times do |j|
      y = -1.0 + j*dy
      n.times do |i|
        x = -1.0 + i*dx
        lon, lat = QuadSphere::CSC.inverse(face, x, y)
        sx = Math::cos(lat) * Math::cos(lon)
        sy = Math::cos(lat) * Math::sin(lon)
        sz = Math::sin(lat)
        a << [sx,sy,sz]
      end
    end
    a
  end
def grid ( face , n ) dx = 2.0 / n dy = 2.0 / n a = Array . new n += 1 n . times do | j | y = - 1.0 + j * dy n . times do | i | x = - 1.0 + i * dx lon , lat = QuadSphere :: CSC . inverse ( face , x , y ) sx = Math :: cos ( lat ) * Math :: cos ( lon ) sy = Math :: cos ( lat ) * Math :: sin ( lon ) sz = Math :: sin ( lat ) a << [ sx , sy , sz ] end end a end
Create a NxN grid of points on a face of the cube.
Create a NxN grid of points on a face of the cube .
face
n