@@ -1382,7 +1382,8 @@ pub extern "C" fn rotate_given_surface_normal(nx: f64, ny: f64, nz: f64, ux: &mu
1382
1382
let v: Vector3 < f64 > = into_surface. cross ( & RUSTBCA_DIRECTION ) ;
1383
1383
let c = into_surface. dot ( & RUSTBCA_DIRECTION ) ;
1384
1384
let vx = Matrix3 :: < f64 > :: new ( 0.0 , -v. z , v. y , v. z , 0.0 , -v. x , -v. y , v. x , 0.0 ) ;
1385
- let rotation_matrix = if c != -1.0 {
1385
+
1386
+ let rotation_matrix = if ( c + 1.0 ) . abs ( ) > 1e-6 {
1386
1387
Matrix3 :: identity ( ) + vx + vx* vx/( 1. + c)
1387
1388
} else {
1388
1389
//If c == -1.0, the correct rotation should simply be a 180 degree rotation
@@ -1394,12 +1395,12 @@ pub extern "C" fn rotate_given_surface_normal(nx: f64, ny: f64, nz: f64, ux: &mu
1394
1395
1395
1396
// ux must not be exactly 1.0 to avoid gimbal lock in RustBCA
1396
1397
// simple_bca does not normalize direction before proceeding, must be done manually
1397
- * ux = incident. x + DELTA ;
1398
1398
assert ! (
1399
- * ux > 0.0 , "Error: RustBCA initial direction out of surface. Please check surface normals and incident direction. n = ({}, {}, {}) u = ({}, {}, {})" ,
1400
- nx, ny, nz, ux, uy, uz
1399
+ incident . x + DELTA > 0.0 , "Error: RustBCA initial direction out of surface. Please check surface normals and incident direction. c={} n = ({}, {}, {}) u = ({}, {}, {}), unew = ({}, {}, {})" ,
1400
+ ( c + 1.0 ) . abs ( ) , nx, ny, nz, ux, uy, uz, incident . x , incident . y , incident . z
1401
1401
) ;
1402
1402
1403
+ * ux = incident. x + DELTA ;
1403
1404
* uy = incident. y - DELTA ;
1404
1405
* uz = incident. z ;
1405
1406
let mag = ( ux. powf ( 2. ) + uy. powf ( 2. ) + uz. powf ( 2. ) ) . sqrt ( ) ;
0 commit comments