File indexing completed on 2026-04-10 07:49:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "OPTICKS_LOG.hh"
0011 #include <cmath>
0012 #include <csignal>
0013
0014 #include "scuda.h"
0015 #include "squad.h"
0016 #include "sqat4.h"
0017 #include "SThetaCut.hh"
0018
0019 #define DEBUG 1
0020 #include "csg_intersect_leaf_head.h"
0021 #include "csg_intersect_leaf_thetacut.h"
0022
0023
0024
0025 bool intersect( float4& is, float4& p, const quad& q0, const quad& q1, char imp, float t_min, const float3& o, const float3& d )
0026 {
0027 bool valid_isect = false ;
0028 switch(imp)
0029 {
0030 case ' ': intersect_leaf_thetacut( valid_isect, is, q0, q1, t_min, o, d ) ; break ;
0031 case 'L': intersect_leaf_thetacut_lucas( valid_isect, is, q0, t_min, o, d ) ; break ;
0032 }
0033
0034 if(valid_isect)
0035 {
0036 float t = is.w ;
0037 p.x = o.x + t*d.x ;
0038 p.y = o.y + t*d.y ;
0039 p.z = o.z + t*d.z ;
0040 p.w = t ;
0041
0042 }
0043
0044 if( valid_isect )
0045 {
0046 printf("// %c o (%10.4f %10.4f %10.4f) d (%10.4f %10.4f %10.4f) p (%10.4f %10.4f %10.4f %10.4f) \n", imp,
0047 o.x, o.y, o.z, d.x, d.y, d.z, p.x, p.y, p.z, p.w );
0048 }
0049 else
0050 {
0051 printf("// %c o (%10.4f %10.4f %10.4f) d (%10.4f %10.4f %10.4f) p (MISS) \n", imp,
0052 o.x, o.y, o.z, d.x, d.y, d.z );
0053 }
0054
0055 return valid_isect ;
0056 }
0057
0058
0059 int main(int argc, char** argv)
0060 {
0061 OPTICKS_LOG(argc, argv);
0062
0063 float startTheta_pi = 0.25 ;
0064 float deltaTheta_pi = 0.5 ;
0065
0066 quad q0, q1 ;
0067 SThetaCut::PrepareParam( q0, q1, startTheta_pi, deltaTheta_pi );
0068
0069 float4 isect = make_float4(0.f, 0.f, 0.f, 0.f );
0070 float4 post = make_float4(0.f, 0.f, 0.f, 0.f );
0071 float t_min = 0.f ;
0072
0073 float3 ray_origin = make_float3( 10.f, 0.f, 0.f );
0074 float3 ray_direction = make_float3( 0.f, 0.f, 1.f );
0075
0076
0077 printf("// x scan \n");
0078 for(float x=-10.f ; x < 10.1f ; x+=0.1f )
0079 {
0080 ray_origin.x = x ;
0081 bool i0 = intersect( isect, post, q0, q1, ' ', t_min, ray_origin, ray_direction );
0082 bool i1 = intersect( isect, post, q0, q1, 'L', t_min, ray_origin, ray_direction );
0083 bool i_expect = i0 == i1 ;
0084 assert( i_expect );
0085 if(!i_expect) std::raise(SIGINT);
0086 }
0087
0088 printf("// z scan \n");
0089 ray_origin.x = 0.f ;
0090 ray_origin.y = 0.f ;
0091
0092 ray_direction.x = 1.f ;
0093 ray_direction.y = 0.f ;
0094 ray_direction.z = 0.f ;
0095
0096 for(float z=-10.f ; z < 10.1f ; z+=0.1f )
0097 {
0098 ray_origin.z = z ;
0099 bool i0 = intersect( isect, post, q0, q1, ' ', t_min, ray_origin, ray_direction );
0100 bool i1 = intersect( isect, post, q0, q1, 'L', t_min, ray_origin, ray_direction );
0101 bool i_expect = i0 == i1 ;
0102 assert( i_expect );
0103 if(!i_expect) std::raise(SIGINT);
0104 }
0105
0106
0107
0108 return 0 ;
0109 }
0110
0111
0112