vec2
2D vector of floats.
Fields and methods
Members of the struct numarray_stack<T,2>. Most of what you do with a CGP type goes through the free functions listed below.
Methods
numarray_stack() | Builds a vector of size 2, 3 or 4 with all coordinates value-initialized (zero for numbers).5 overloads src |
numarray_stack(T const& x, T const& y) | Builds a 2D vector from its coordinates x and y. src |
numarray_stack(numarray_stack<T,3> const& v) | Builds a 2D vector from the x and y coordinates of a 3D vector, dropping z (not explicit, so a vec3 converts implicitly to a vec2). src |
numarray_stack(numarray_stack<T,4> const& v) | Builds a 2D vector from the x and y coordinates of a 4D vector, dropping z and w (not explicit, so a vec4 converts implicitly to a vec2). src |
numarray_stack(T1 const& x, T2 const& y) | Builds a 2D vector from two coordinates of other types, converted to T. src |
| Number of components N, fixed at compile time. src | |
| Sets the N components to the given value and returns the vector. src | |
| Returns the element at index, bound-checked unless CGP_NO_DEBUG is defined. src | |
| Returns a const reference to the element at the given index, with bound checking unless CGP_NO_DEBUG is defined. src | |
| Returns a const reference to the element at the given index; bound-checked for sizes 2, 3 and 4 (vec2, vec3, vec4) unless CGP_NO_DEBUG is defined, but not checked for the other sizes N. src | |
| Returns a const iterator to the first element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator one past the last element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator to the first element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator one past the last element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const reference to the element at the given index, without bound checking. src |
Functions taking a vec2
Construct 2
Documented on another page
tensor_productOuter product a * transpose(b), as a 2x2 matrix.onmat2trackball_rotationRotation moving the trackball projection of p0 onto that of p1, identity if the two points are closer than 1e-4.onrotation_transform
Transform 1
vec2 orthogonal_vector(vec2 const& v)Unit vector orthogonal to v (v rotated by -90 degrees and normalized); returns (1,0) for a zero vector.
Compute 6
float noise_perlin(
vec2 const& p,
int octave = 5,
float persistency = 0.3f,
float frequency_gain = 2.0f
)Fractal 2D noise in [0,1] summing octave layers of simplex noise, each layer scaled in amplitude by persistency and in frequency by frequency_gain (defaults 5, 0.3, 2).
picking_structure picking_mesh_vertex_as_sphere(
vec2 const& screen_click,
numarray<vec3> const& vertex_position,
numarray<vec3> const& vertex_normal,
float picking_distance,
camera_generic_base const& camera,
camera_projection_perspective const& projection
)Casts the camera ray through the screen position and returns the closest vertex whose sphere of radius picking_distance it hits, with the hit point, the vertex normal and the vertex index (active is false if none).
intersection_structure picking_plane_orthogonal_to_camera(
vec2 const& screen_position,
vec3 const& plane_position,
camera_generic_base const& camera,
camera_projection_perspective const& projection
)Intersects the camera ray through the screen position (relative coordinates) with the plane through plane_position orthogonal to the front direction of the camera.
picking_structure picking_spheres(
vec2 const& screen_click,
numarray<vec3> const& spheres_centers,
float spheres_radius,
camera_generic_base const& camera,
camera_projection_perspective const& projection
)Cast a ray through a screen position (normalized device coordinates) and return the closest hit among spheres of common radius, with its index, position and normal.
vec3 translation_in_plane(vec2 const& translation, rotation_transform const& plane_orientation)3D vector of a 2D translation expressed in the xy plane of the given orientation.
Documented on another page
camera_ray_directionUnit world-space direction of the ray through a screen position given in normalized device coordinates [-1,1]^2, from the camera frame and the inverse projection matrix.onmat4
Convert 2
Access 2
template <typename T, int N, typename INDEX_TYPE>
void check_index_bounds(INDEX_TYPE index, numarray_stack<T,2> const& data)Raises an error if the index is outside [0, 1]; no-op when CGP_NO_DEBUG is defined.
Other 1
Documented on another page
opengl_uniformSend a vec2 uniform to the shader; warns if the uniform is not found and expected is true.onopengl_shader_structure
Functions returning a vec2
Access 1
Documented on another page
getRow idx1 as a vector, with the index checked at compile time (static_assert).onmatN
Operators
None besides the shared functions above.