MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / intersect

Method intersect

examples/pde/bhrt.cpp:805–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803 }
804
805 std::pair<HasHit, HitPos> intersect(
806 const af::array& ray_begin, const af::array& ray_end) const override {
807 uint32_t count = ray_begin.dims()[1];
808
809 // Compute intersection of ray with a plane
810 af::array has_hit = af::constant(0, count).as(b8);
811 af::array hit_pos = ray_end;
812 af::array a = dot3(normal, center - ray_begin);
813 af::array b = dot3(normal, ray_end - ray_begin);
814 af::array t = af::select(b != 0.0, a / b, (double)0.0);
815
816 af::array plane_intersect = (ray_end - ray_begin) * t + ray_begin;
817 af::array dist = norm3(plane_intersect - center);
818
819 t = af::abs(t);
820
821 // Determine if the intersection falls inside the disk radius and occurs
822 // with the current ray segment
823 has_hit = af::moddims((dist < outter_radius) && (t <= 1.0) &&
824 (t > 0.0) && (dist > inner_radius),
825 af::dim4(count));
826 hit_pos = plane_intersect;
827
828 return {has_hit, hit_pos};
829 }
830
831 af::array get_color(const af::array& ray_begin,
832 const af::array& ray_end) const override {

Callers

nothing calls this directly

Calls 9

constantFunction · 0.85
dot3Function · 0.85
norm3Function · 0.85
moddimsFunction · 0.85
asMethod · 0.80
selectFunction · 0.50
absFunction · 0.50
dim4Class · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected