@@ -31,30 +31,31 @@ public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, usho
3131 }
3232
3333 // New XY is calculated based on flipping and rotating the input XY.
34- // Coordinates are normalized to a range of 0-1 so we can pass a constant integer size to the transform builder.
35- Vector2 normalized = Normalize ( position , min , max ) ;
34+ // Coordinate ranges are normalized to a range of 0-1 so we can pass a
35+ // constant integer size to the transform builder.
36+ Vector2 scaled = Scale ( position , min , max ) ;
3637 AffineTransformBuilder builder = new ( ) ;
3738 Size size = new ( 1 , 1 ) ;
3839 switch ( orientation )
3940 {
4041 case ExifOrientationMode . TopRight :
41- builder . AppendTranslation ( new Vector2 ( FlipNormalized ( normalized . X ) , 0 ) ) ;
42+ builder . AppendTranslation ( new Vector2 ( FlipScaled ( scaled . X ) , 0 ) ) ;
4243 break ;
4344 case ExifOrientationMode . BottomRight :
4445 builder . AppendRotationDegrees ( 180 ) ;
4546 break ;
4647 case ExifOrientationMode . BottomLeft :
47- builder . AppendTranslation ( new Vector2 ( 0 , FlipNormalized ( normalized . Y ) ) ) ;
48+ builder . AppendTranslation ( new Vector2 ( 0 , FlipScaled ( scaled . Y ) ) ) ;
4849 break ;
4950 case ExifOrientationMode . LeftTop :
50- builder . AppendTranslation ( new Vector2 ( FlipNormalized ( normalized . X ) , 0 ) ) ;
51+ builder . AppendTranslation ( new Vector2 ( FlipScaled ( scaled . X ) , 0 ) ) ;
5152 builder . AppendRotationDegrees ( 270 ) ;
5253 break ;
5354 case ExifOrientationMode . RightTop :
5455 builder . AppendRotationDegrees ( 270 ) ;
5556 break ;
5657 case ExifOrientationMode . RightBottom :
57- builder . AppendTranslation ( new Vector2 ( FlipNormalized ( normalized . X ) , 0 ) ) ;
58+ builder . AppendTranslation ( new Vector2 ( FlipScaled ( scaled . X ) , 0 ) ) ;
5859 builder . AppendRotationDegrees ( 90 ) ;
5960 break ;
6061 case ExifOrientationMode . LeftBottom :
@@ -65,7 +66,7 @@ public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, usho
6566 }
6667
6768 Matrix3x2 matrix = builder . BuildMatrix ( size ) ;
68- return DeNormalize ( Vector2 . Transform ( normalized , matrix ) , min , max ) ;
69+ return DeScale ( Vector2 . Transform ( scaled , matrix ) , min , max ) ;
6970 }
7071
7172 /// <summary>
@@ -194,12 +195,12 @@ or ExifOrientationMode.RightBottom
194195 } ;
195196
196197 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
197- private static Vector2 Normalize ( Vector2 x , Vector2 min , Vector2 max ) => ( x - min ) / ( max - min ) ;
198+ private static Vector2 Scale ( Vector2 x , Vector2 min , Vector2 max ) => ( x - min ) / ( max - min ) ;
198199
199200 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
200- private static Vector2 DeNormalize ( Vector2 x , Vector2 min , Vector2 max ) => min + ( x * ( max - min ) ) ;
201+ private static Vector2 DeScale ( Vector2 x , Vector2 min , Vector2 max ) => min + ( x * ( max - min ) ) ;
201202
202203 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
203- private static float FlipNormalized ( float origin ) => ( 2F * - origin ) + 1F ;
204+ private static float FlipScaled ( float origin ) => ( 2F * - origin ) + 1F ;
204205 }
205206}
0 commit comments