11const std = @import ("std" );
2- const zla = @import ("../root.zig" );
3- const geometry = zla .geom ;
2+ const zml = @import ("../root.zig" );
3+ const geometry = zml .geom ;
44
55pub fn AABB (comptime T : type ) type {
66 return struct {
@@ -34,7 +34,7 @@ pub fn AABB(comptime T: type) type {
3434 }
3535
3636 pub fn get_sqr_distance_to (self : Self , point : @Vector (3 , T )) T {
37- return zla .vec .norm_sqr (self .get_closest_point (point ) - point );
37+ return zml .vec .norm_sqr (self .get_closest_point (point ) - point );
3838 }
3939
4040 pub fn from_two_points (p1 : @Vector (3 , T ), p2 : @Vector (3 , T )) @This () {
@@ -53,7 +53,7 @@ pub fn AABB(comptime T: type) type {
5353 };
5454 }
5555
56- pub fn transform (self : Self , mat : zla .Mat (T , 4 , 4 )) Self {
56+ pub fn transform (self : Self , mat : zml .Mat (T , 4 , 4 )) Self {
5757 const pos = mat .position ();
5858 var new_min = pos ;
5959 var new_max = pos ;
@@ -107,7 +107,7 @@ pub fn AABB(comptime T: type) type {
107107 pub fn surface_area (self : Self ) T {
108108 std .debug .assert (@reduce (.And , self .min <= self .max ));
109109 const extent = self .max - self .min ;
110- return 2 * zla .vec .dot (zla .vec .swizzle (extent , "yzz" ), zla .vec .swizzle (extent , "xxy" ));
110+ return 2 * zml .vec .dot (zml .vec .swizzle (extent , "yzz" ), zml .vec .swizzle (extent , "xxy" ));
111111 }
112112
113113 pub fn volume (self : Self ) T {
@@ -121,11 +121,11 @@ pub fn AABB(comptime T: type) type {
121121test "aabb_transform" {
122122 const AABBf32 = AABB (f32 );
123123 const aabb = AABBf32 .from_two_points (.{ 0.0 , 0.0 , 0.0 }, .{ 1.0 , 1.0 , 1.0 });
124- var translation : zla .Mat (f32 , 4 , 4 ) = .identity ;
124+ var translation : zml .Mat (f32 , 4 , 4 ) = .identity ;
125125 translation = translation .translate (.{ 1.0 , 2.0 , 3.0 });
126126 const transformed = aabb .transform (translation );
127- try std .testing .expect (zla .vec .is_close_default (transformed .min , .{ 1.0 , 2.0 , 3.0 }));
128- try std .testing .expect (zla .vec .is_close_default (transformed .max , .{ 2.0 , 3.0 , 4.0 }));
127+ try std .testing .expect (zml .vec .is_close_default (transformed .min , .{ 1.0 , 2.0 , 3.0 }));
128+ try std .testing .expect (zml .vec .is_close_default (transformed .max , .{ 2.0 , 3.0 , 4.0 }));
129129}
130130
131131test "surface_area" {
@@ -153,14 +153,14 @@ test "InvDirection" {
153153test "aabb_get_support" {
154154 const aabb : AABB (f32 ) = .from_two_points (.{ 0.0 , 0.0 , 0.0 }, .{ 1.0 , 1.0 , 1.0 });
155155
156- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ 0.5774 , 0.5774 , 0.5774 }), .{ 0.0 , 0.0 , 0.0 }));
157- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ 0.5774 , 0.5774 , -0.5774 }), .{ 0.0 , 0.0 , 1.0 }));
158- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ 0.5774 , -0.5774 , 0.5774 }), .{ 0.0 , 1.0 , 0.0 }));
159- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ 0.5774 , -0.5774 , -0.5774 }), .{ 0.0 , 1.0 , 1.0 }));
160- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ -0.5774 , 0.5774 , 0.5774 }), .{ 1.0 , 0.0 , 0.0 }));
161- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ -0.5774 , 0.5774 , -0.5774 }), .{ 1.0 , 0.0 , 1.0 }));
162- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ -0.5774 , -0.5774 , 0.5774 }), .{ 1.0 , 1.0 , 0.0 }));
163- try std .testing .expect (zla .vec .is_close_default (aabb .get_support (.{ -0.5774 , -0.5774 , -0.5774 }), .{ 1.0 , 1.0 , 1.0 }));
156+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ 0.5774 , 0.5774 , 0.5774 }), .{ 0.0 , 0.0 , 0.0 }));
157+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ 0.5774 , 0.5774 , -0.5774 }), .{ 0.0 , 0.0 , 1.0 }));
158+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ 0.5774 , -0.5774 , 0.5774 }), .{ 0.0 , 1.0 , 0.0 }));
159+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ 0.5774 , -0.5774 , -0.5774 }), .{ 0.0 , 1.0 , 1.0 }));
160+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ -0.5774 , 0.5774 , 0.5774 }), .{ 1.0 , 0.0 , 0.0 }));
161+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ -0.5774 , 0.5774 , -0.5774 }), .{ 1.0 , 0.0 , 1.0 }));
162+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ -0.5774 , -0.5774 , 0.5774 }), .{ 1.0 , 1.0 , 0.0 }));
163+ try std .testing .expect (zml .vec .is_close_default (aabb .get_support (.{ -0.5774 , -0.5774 , -0.5774 }), .{ 1.0 , 1.0 , 1.0 }));
164164}
165165
166166//const Plane = struct {
0 commit comments