Package: graphene

Macro graphene:with-point3d

Lambda List

graphene:with-point3d ((var &rest args) &body body)

Syntax

(graphene:with-point3d (p) body) => result
(graphene:with-point3d (p p1) body) => result
(graphene:with-point3d (p (v graphene:vec3-t)) body) => result
(graphene:with-point3d (p x y z) body) => result

Arguments

p -- a graphene:point3d-t instance to create and initialize
p1 -- a graphene:point3d-t instance to use for initialization
v -- a graphene:vec3-t instance to use for initialization
x -- a number coerced to a float for the x component of the point
y -- a number coerced to a float for the y component of the point
z -- a number coerced to a float for the z component of the point

Details

The graphene:with-point3d macro allocates a new graphene:point3d-t instance, initializes the point with the given values and executes the body that uses the point. After execution of the body the allocated memory for the point is released.

When no argument is given the components of the point are initialized to zero. The initialization with three single floats uses the graphene:point3d-init function. The initialization from another point is done with the graphene:point3d-init-from-point function. That is the default when no type specifier for the value is given. If the value has the type specifier graphene:vec3-t the point is initialized with the graphene:point3d-init-from-vec3 function.

Note

The memory is allocated with the graphene:point3d-alloc function and released with the graphene:point3d-free function.

Examples

Initialize a point with no value and three single floats.
(graphene:with-point3d (p)
  (list (graphene:point3d-x p) (graphene:point3d-y p) (graphene:point3d-z p)))
=> (0.0 0.0 0.0)
(graphene:with-point3d (p 1.5 1.7 1.9)
  (list (graphene:point3d-x p) (graphene:point3d-y p) (graphene:point3d-z p)))
=> (1.5 1.7 1.9)    
Use a vector for initialization of the point.
(graphene:with-vec3 (v 3.5 4.5 5.5)
  (graphene:with-point3d (p (v graphene:vec3-t))
    (list (graphene:point3d-x p)
          (graphene:point3d-y p)
          (graphene:point3d-z p))))
=> (3.5 4.5 5.5)    
This examples uses the graphene:with-point3ds macro to initialize two points. The second point is intialized with the values from the first point.
(graphene:with-point3ds ((p1 0.3 0.5 0.7) (p2 p1))
  (list (graphene:point3d-x p2)
        (graphene:point3d-y p2)
        (graphene:point3d-z p2)))
=> (0.3 0.5 0.7)    
 

See also

2024-1-20