[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 Vector arrays and point arrays

Class: <vector4f-array>
Class: <point4f-array>

Represents an array of vector4fs and point4fs. This is an efficient way to keep an array of vectors or points, for the elements are packed in a simple float array. They are especially useful to work with GL's vertex array feature. gl-vertex-pointer can take <point4f-array>, and gl-normal-pointer can take <vector4f-array>.

It is also possible to "view" a plain f32vector as <vector4f-array> or <point4f-array> without copying its content, by f32vector->vector4f-array/shared and f32vector->point4f-array/shared. Combined to read-block!, you can do efficient binary I/O of vertex arrays, for example.

Inherits <sequence> and <collection>. When viewed as a sequence or a collection, they behaves like sequence or collection of vector4f and point4f objects, respectively.

Function: make-vector4f-array len &optional init-vector
Function: make-point4f-array len &optional init-point

Creates a vector4f-array or point4f-array with len elements. Each element is initialized by a vector4f init-vector or a point4f init-point if provided.

Function: vector4f-array? obj
Function: point4f-array? obj

Returns true iff obj is a vector4f-array or a point4f-array, respectively.

Function: vector4f-array-length array
Function: point4f-array-length array

Returns length (number of vectors/points) in array array.

Reader syntax: #,(vector4f-array len elt …)
Reader syntax: #,(point4f-array len elt …)

Vector4f-array and point4f-array have external representation using this SRFI-10 syntax. Len is a length of array, and each elt is a list of four floats representing each element of the array.

 
(f32vector->vector4f-array #f32(1 2 3 4 6 7 4 3))
  ⇒ #,(vector4f-array 2 (1 2 3 4) (6 7 4 3) )
Function: list->vector4f-array list
Function: list->point4f-array list

From given list of vector4fs or point4fs, creates and returns a vector4f-array or point4f-array, respectively.

Function: f32vector->vector4f-array v
Function: f32vector->point4f-array v

Converts f32vector v to a vector4f-array or a point4f-array. The length of v must be multiple of four. The content of v is copied.

 
(f32vector->vector4f-array v)
  ≡ (coerce-to <vector4f-array> v)
Function: f32vector->vector4f-array/shared v
Function: f32vector->point4f-array/shared v

Like above, but the content of v is shared by the result array, instead of being copied. So the modification of result array will be visible from original f32vector v and vice versa. It will allow efficient handling of large vertex arrays.

Function: vector4f-array->f32vector array
Function: point4f-array->f32vector array

Converts a vector4f-array or a point4f-array array to a f32vector.

 
(vector4f-array->f32vector array)
  ≡ (coerce-to <f32vector> array)
Function: vector4f-array-set! array i vector
Function: point4f-array-set! array i point

Sets a vector4f vector or a point4f point to i-th element of vector4f-array or point4f-array array, respectively.

 
(vector4f-array-set! array i vector)
  ≡ (set! (ref array i) vector)
Function: vector4f-array-ref array i &optional fallback
Function: point4f-array-ref array i &optional fallback

Returns a vector4f or a point4f which is the i-th element of array array, respectively. If k is out of range, an error is signalled, unless fallback is provided, in such a case fallback is returned.

 
(vector4f-array-ref array i)
  ≡ (ref array i)

(ref #,(vector4f-array 2 (1 2 3 4) (6 7 4 3))  1)
  ⇒ #,(vector4f 6 7 4 3)
Function: vector4f-array-ref/shared array i &optional fallback
Function: point4f-array-ref/shared array i &optional fallback

Like above, but the returned vector4f or point4f shares the storage with the original array. Thus the modification of the result vector or point will be visible from array, and vice versa.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on June, 7 2008 using texi2html 1.78.