Class: CGLM::Plane

Inherits:
Vec4 show all
Defined in:
lib/cglm/plane.rb,
ext/cglm/rb_cglm.c

Instance Attribute Summary

Attributes inherited from Base

#addr

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vec4

#*, #+, #-, #/, #==, #=~, #[], #[]=, #add_scalar, #add_scalar!, #add_vec4, #add_vec4!, #addadd, #addadd_vec4, black, #broadcast!, #clamp, #clamp!, #clamp_scalar, #clamp_scalar!, #clamp_vec4, #clamp_vec4!, #copy_to, #distance, #div_scalar, #div_scalar!, #div_vec4, #div_vec4!, #dot, #equalish_scalar, #equalish_vec4, #equals_all, #equals_scalar, #equals_vec4, #flip_signs, #flip_signs!, #highest, #inf?, #inspect, #lerp!, #lowest, #luminance, #max, #min, #mul_scalar, #mul_scalar!, #mul_vec4, #mul_vec4!, #muladd, #muladd_scalar, #muladd_vec4, #nan?, #norm, #norm2, one, #one!, rand, random, #resize, #resize!, #signs, #size, #sqrt, #sub_scalar, #sub_scalar!, #sub_vec4, #sub_vec4!, #subadd, #subadd_vec4, #to_vec3, #valid?, zero, #zero!

Methods inherited from VectorType

#each, #to_a, #to_enum

Methods inherited from Base

#copy_to, #dup, #initialize_dup

Constructor Details

#initialize(normal, distance) ⇒ Plane

Returns a new Vec4 representing a plane with the given normal (a Vec3) and distance (a number).



5
6
7
# File 'lib/cglm/plane.rb', line 5

def initialize(normal, distance)
  super [*normal, distance]
end

Class Method Details

.alignmentObject



28
# File 'ext/cglm/rb_cglm_plane.c', line 28

VALUE rb_cglm_plane_alignment_bytes(VALUE klass) { return SIZET2NUM(PLANE_ALIGNMENT); }

.sizeObject



26
# File 'ext/cglm/rb_cglm_plane.c', line 26

VALUE rb_cglm_plane_size_bytes(VALUE klass) { return SIZET2NUM(plane_size()); }

Instance Method Details

#normalize([dest]) ⇒ dest | new Plane

Normalizes this plane and places the result in dest, or allocates a new Plane if dest is omitted.

Returns:



8
9
10
11
12
13
14
15
# File 'ext/cglm/rb_cglm_plane.c', line 8

VALUE rb_cglm_plane_normalize(int argc, VALUE *argv, VALUE self) {
  VALUE dest;
  rb_scan_args(argc, argv, "01", &dest);
  if (NIL_P(dest)) dest = PLANE_NEW(ALLOC_PLANE);
  memcpy(&(VAL2VEC4(self)), &(VAL2VEC4(dest)), sizeof(vec4));
  glm_plane_normalize(VAL2VEC4(dest));
  return dest;
}

#normalize!self

Normalizes this Vec4 (which represents a plane) and returns it.

Returns:

  • (self)


21
22
23
24
# File 'ext/cglm/rb_cglm_plane.c', line 21

VALUE rb_cglm_plane_normalize_self(VALUE self) {
  glm_plane_normalize(VAL2VEC4(self));
  return self;
}