Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:26

0001 /**
0002 intersect_leaf_cylinder_test.cc
0003 ===================================
0004 
0005 **/
0006 
0007 #include "OPTICKS_LOG.hh"
0008 #include <cmath>
0009 
0010 
0011 #include "scuda.h"
0012 #include "squad.h"
0013 #include "sqat4.h"
0014 
0015 #define DEBUG 1 
0016 #include "csg_intersect_leaf_head.h"
0017 #include "csg_robust_quadratic_roots.h"
0018 
0019 #include "csg_intersect_leaf_cylinder.h"
0020 #include "csg_intersect_leaf_oldcylinder.h"
0021 
0022 
0023 void lowlevel_test()
0024 {
0025     quad q0, q1 ; 
0026     q0.f.x = 0.f ;  
0027     q0.f.y = 0.f ; 
0028     q0.f.z = 0.f ; 
0029     q0.f.w = 10.f ;  // radius
0030     
0031     q1.f.x = -5.f ;  // z1 
0032     q1.f.y =  5.f ;  // z2 
0033     q1.f.z =  0.f ; 
0034     q1.f.w =  0.f ; 
0035 
0036 
0037     float t_min = 0.f ; 
0038     float3 ray_origin    = make_float3(  0.f, 0.f, 0.f ); 
0039     float3 ray_direction = make_float3(  0.f, 0.f, 1.f ); 
0040 
0041     float4 isect0 = make_float4(0.f, 0.f, 0.f, 0.f ); 
0042     float4 isect1 = make_float4(0.f, 0.f, 0.f, 0.f ); 
0043 
0044     bool valid_isect0(false) ;  
0045     intersect_leaf_cylinder( valid_isect0, isect0, q0, q1, t_min, ray_origin, ray_direction ); 
0046     bool valid_isect1(false) ;  
0047     intersect_leaf_oldcylinder( valid_isect1, isect1, q0, q1, t_min, ray_origin, ray_direction ); 
0048 
0049 
0050 
0051     //float3 pos0 = make_float3( 0.f , 0.f, 0.f ); 
0052     //float3 pos1 = make_float3( 0.f , 0.f, 0.f ); 
0053 
0054     if(valid_isect0 && valid_isect1 )
0055     {
0056         float t0 = isect0.w ; 
0057         float t1 = isect1.w ; 
0058 
0059         printf("// t0 %10.4f t1 %10.4f \n", t0, t1 ); 
0060 
0061         /*
0062         pos0  = ray_origin + t0*ray_direction  ; 
0063         pos1  = ray_origin + t1*ray_direction  ; 
0064 
0065         float sd0 = distance_leaf_cylinder(pos0, q0, q1) ; 
0066         float sd1 = distance_leaf_cylinder(pos1, q0, q1) ; 
0067         */
0068 
0069     }
0070 
0071 }
0072 
0073 int main(int argc, char** argv)
0074 {
0075     OPTICKS_LOG(argc, argv); 
0076 
0077     lowlevel_test(); 
0078 
0079 
0080     return 0 ; 
0081 }
0082 
0083 
0084