@@ -21,10 +21,10 @@ impl<X: Ranged, Y: Ranged, Z: Ranged> Cartesian3d<X, Y, Z> {
21
21
fn create_projection < F : FnOnce ( ProjectionMatrixBuilder ) -> ProjectionMatrix > (
22
22
actual_x : Range < i32 > ,
23
23
actual_y : Range < i32 > ,
24
+ coord_size : ( i32 , i32 , i32 ) ,
24
25
f : F ,
25
26
) -> ProjectionMatrix {
26
- let default_size = Self :: compute_default_size ( actual_x. clone ( ) , actual_y. clone ( ) ) ;
27
- let center_3d = ( default_size / 2 , default_size / 2 , default_size / 2 ) ;
27
+ let center_3d = ( coord_size. 0 / 2 , coord_size. 1 / 2 , coord_size. 2 / 2 ) ;
28
28
let center_2d = (
29
29
( actual_x. end + actual_x. start ) / 2 ,
30
30
( actual_y. end + actual_y. start ) / 2 ,
@@ -46,22 +46,41 @@ impl<X: Ranged, Y: Ranged, Z: Ranged> Cartesian3d<X, Y, Z> {
46
46
build_projection_matrix : F ,
47
47
) -> Self {
48
48
let default_size = Self :: compute_default_size ( actual_x. clone ( ) , actual_y. clone ( ) ) ;
49
+ let coord_size = ( default_size, default_size, default_size) ;
49
50
Self {
50
51
logic_x : logic_x. into ( ) ,
51
52
logic_y : logic_y. into ( ) ,
52
53
logic_z : logic_z. into ( ) ,
53
- coord_size : ( default_size, default_size, default_size) ,
54
- projection : Self :: create_projection ( actual_x, actual_y, build_projection_matrix) ,
54
+ coord_size,
55
+ projection : Self :: create_projection (
56
+ actual_x,
57
+ actual_y,
58
+ coord_size,
59
+ build_projection_matrix,
60
+ ) ,
55
61
}
56
62
}
63
+
64
+ pub fn set_coord_pixel_range (
65
+ & mut self ,
66
+ actual_x : Range < i32 > ,
67
+ actual_y : Range < i32 > ,
68
+ coord_size : ( i32 , i32 , i32 ) ,
69
+ ) -> & mut Self {
70
+ self . coord_size = coord_size;
71
+ self . projection =
72
+ Self :: create_projection ( actual_x, actual_y, coord_size, |pb| pb. into_matrix ( ) ) ;
73
+ self
74
+ }
75
+
57
76
/// Set the projection matrix
58
77
pub fn set_projection < F : FnOnce ( ProjectionMatrixBuilder ) -> ProjectionMatrix > (
59
78
& mut self ,
60
79
actual_x : Range < i32 > ,
61
80
actual_y : Range < i32 > ,
62
81
f : F ,
63
82
) -> & mut Self {
64
- self . projection = Self :: create_projection ( actual_x, actual_y, f) ;
83
+ self . projection = Self :: create_projection ( actual_x, actual_y, self . coord_size , f) ;
65
84
self
66
85
}
67
86
0 commit comments