Class: CGLM::Sphere
- Inherits:
-
Vec4
- Object
- Base
- VectorType
- Vec4
- CGLM::Sphere
- Defined in:
- lib/cglm/sphere.rb,
ext/cglm/rb_cglm.c
Overview
Sphere Representation in cglm: [center.x, center.y, center.z, radius]
You could use this representation or you can convert it to Vec4 before calling any function.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#contains_point?(point) ⇒ Boolean
Returns true if
self
contains the specified Vec3, false otherwise. -
#intersects_sphere?(other) ⇒ Boolean
Returns true if
self
intersectsother
, false otherwise. -
#merge(other[, dest]) ⇒ dest | new Sphere
Merges two spheres (
self
andother
) and places the result indest
. - #radius ⇒ Object
-
#transform(mat4[, dest]) ⇒ dest | new Sphere
Transforms this sphere to put it in the space described by
mat4
, and puts the result intodest
.
Methods inherited from Vec4
#*, #+, #-, #/, #==, #=~, #[], #[]=, #add_scalar, #add_scalar!, #add_vec4, #add_vec4!, #addadd, #addadd_vec4, alignment, 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, #normalize, #normalize!, one, #one!, rand, random, #resize, #resize!, #signs, size, #size, #sqrt, #sub_scalar, #sub_scalar!, #sub_vec4, #sub_vec4!, #subadd, #subadd_vec4, #to_vec3, #valid?, zero, #zero!
Methods inherited from VectorType
#each, #initialize, #to_a, #to_enum
Methods inherited from Base
#copy_to, #dup, #initialize, #initialize_dup
Constructor Details
This class inherits a constructor from CGLM::VectorType
Instance Method Details
#contains_point?(point) ⇒ Boolean
Returns true if self
contains the specified Vec3, false otherwise.
48 49 50 |
# File 'ext/cglm/rb_cglm_sphere.c', line 48
VALUE rb_cglm_sphere_contains_point(VALUE self, VALUE point) {
return glm_sphere_point(VAL2VEC4(self), VAL2VEC3(point)) ? Qtrue : Qfalse;
}
|
#intersects_sphere?(other) ⇒ Boolean
Returns true if self
intersects other
, false otherwise.
other
must be a Sphere or a Vec4 with the layout[x, y, z, radius]
.
40 41 42 |
# File 'ext/cglm/rb_cglm_sphere.c', line 40
VALUE rb_cglm_sphere_intersects_sphere(VALUE self, VALUE other) {
return glm_sphere_sphere(VAL2VEC4(self), VAL2VEC4(other)) ? Qtrue : Qfalse;
}
|
#merge(other[, dest]) ⇒ dest | new Sphere
Merges two spheres (self
and other
) and places the result in dest
. If
dest
is omitted, a new Sphere will be created.
Both spheres must be in the same space. For instance, if one is in world space then the other must be in world space and not in local space.
other
must be a Sphere or a Vec4 with the layout[x, y, z, radius]
.
26 27 28 29 30 31 32 |
# File 'ext/cglm/rb_cglm_sphere.c', line 26
VALUE rb_cglm_sphere_merge(int argc, VALUE *argv, VALUE self) {
VALUE other, dest;
rb_scan_args(argc, argv, "11", &other, &dest);
if (NIL_P(dest)) dest = rb_funcall(rb_cSphere, rb_intern("new"), 0);
glm_sphere_merge(VAL2VEC4(self), VAL2VEC4(other), VAL2VEC4(dest));
return dest;
}
|
#radius ⇒ Object
7 8 9 |
# File 'lib/cglm/sphere.rb', line 7 def radius self[3] end |
#transform(mat4[, dest]) ⇒ dest | new Sphere
Transforms this sphere to put it in the space described by mat4
, and
puts the result into dest
. If dest
is omitted, a new Sphere is created.
8 9 10 11 12 13 14 |
# File 'ext/cglm/rb_cglm_sphere.c', line 8
VALUE rb_cglm_sphere_transform(int argc, VALUE *argv, VALUE self) {
VALUE matrix, dest;
rb_scan_args(argc, argv, "11", &matrix, &dest);
if (NIL_P(dest)) dest = rb_funcall(rb_cSphere, rb_intern("new"), 0);
glm_sphere_transform(VAL2VEC4(self), VAL2MAT4(matrix), VAL2VEC4(dest));
return dest;
}
|