diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs
index 45556741e6..c0c8e07e6f 100644
--- a/src/ImageSharp/Common/Helpers/ImageMaths.cs
+++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs
@@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp
/// Converts degrees to radians
///
[MethodImpl(InliningOptions.ShortMethod)]
- public static float ToRadian(float degrees)
+ public static float DegreesToRadians(float degrees)
{
return degrees * ((float)Math.PI / 180f);
}
diff --git a/src/ImageSharp/Processing/AffineTransformBuilder.cs b/src/ImageSharp/Processing/AffineTransformBuilder.cs
index cd66272b42..1f26d079d4 100644
--- a/src/ImageSharp/Processing/AffineTransformBuilder.cs
+++ b/src/ImageSharp/Processing/AffineTransformBuilder.cs
@@ -42,37 +42,38 @@ namespace SixLabors.ImageSharp.Processing
///
internal Size Size => this.sourceRectangle.Size;
+
///
- /// Prepends a centered rotation matrix using the given rotation in degrees.
+ /// Prepends a centered rotation matrix using the given rotation in radians.
///
- /// The amount of rotation, in degrees.
+ /// The amount of rotation, in radians.
/// The .
- public AffineTransformBuilder PrependRotationDegrees(float degrees)
- => this.PrependMatrix(TransformUtils.CreateRotationMatrixDegrees(degrees, this.Size));
+ public AffineTransformBuilder PrependCenteredRotationRadians(float radians)
+ => this.PrependMatrix(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
///
- /// Prepends a centered rotation matrix using the given rotation in radians.
+ /// Appends a centered rotation matrix using the given rotation in radians.
///
/// The amount of rotation, in radians.
/// The .
- public AffineTransformBuilder PrependRotationRadians(float radians)
- => this.PrependMatrix(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
+ public AffineTransformBuilder AppendCenteredRotationRadians(float radians)
+ => this.AppendMatrix(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
///
- /// Appends a centered rotation matrix using the given rotation in degrees.
+ /// Prepends a centered rotation matrix using the given rotation in degrees.
///
/// The amount of rotation, in degrees.
/// The .
- public AffineTransformBuilder AppendRotationDegrees(float degrees)
- => this.AppendRotationRadians(ImageMaths.ToRadian(degrees));
+ public AffineTransformBuilder PrependCenteredRotationDegrees(float degrees)
+ => this.PrependCenteredRotationRadians(ImageMaths.DegreesToRadians(degrees));
///
- /// Appends a centered rotation matrix using the given rotation in radians.
+ /// Appends a centered rotation matrix using the given rotation in degrees.
///
- /// The amount of rotation, in radians.
+ /// The amount of rotation, in degrees.
/// The .
- public AffineTransformBuilder AppendRotationRadians(float radians)
- => this.AppendMatrix(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
+ public AffineTransformBuilder AppendCenteredRotationDegrees(float degrees)
+ => this.AppendCenteredRotationRadians(ImageMaths.DegreesToRadians(degrees));
///
/// Prepends a scale matrix from the given uniform scale.
diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs
index 6c5fb46259..58c02108ac 100644
--- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs
+++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs
@@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing
Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle));
this.sourceRectangle = sourceRectangle;
- }
+ }
///
/// Gets the source image size.
@@ -63,16 +63,44 @@ namespace SixLabors.ImageSharp.Processing
public ProjectiveTransformBuilder AppendTaperMatrix(TaperSide side, TaperCorner corner, float fraction)
=> this.AppendMatrix(TransformUtils.CreateTaperMatrix(this.Size, side, corner, fraction));
- public void AppendRotationRadians(float radians)
+ ///
+ /// Prepends a centered rotation matrix using the given rotation in radians.
+ ///
+ /// The amount of rotation, in radians.
+ /// The .
+ public ProjectiveTransformBuilder PrependCenteredRotationRadians(float radians)
{
- throw new System.NotImplementedException();
+ var m = new Matrix4x4(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
+ return this.PrependMatrix(m);
}
- public void PrependRotationRadians(float radians)
+ ///
+ /// Appends a centered rotation matrix using the given rotation in radians.
+ ///
+ /// The amount of rotation, in radians.
+ /// The .
+ public ProjectiveTransformBuilder AppendCenteredRotationRadians(float radians)
{
- throw new System.NotImplementedException();
+ var m = new Matrix4x4(TransformUtils.CreateRotationMatrixRadians(radians, this.Size));
+ return this.AppendMatrix(m);
}
+ ///
+ /// Prepends a centered rotation matrix using the given rotation in degrees.
+ ///
+ /// The amount of rotation, in degrees.
+ /// The .
+ public ProjectiveTransformBuilder PrependCenteredRotationDegrees(float degrees)
+ => this.PrependCenteredRotationRadians(ImageMaths.DegreesToRadians(degrees));
+
+ ///
+ /// Appends a centered rotation matrix using the given rotation in degrees.
+ ///
+ /// The amount of rotation, in degrees.
+ /// The .
+ public ProjectiveTransformBuilder AppendCenteredRotationDegrees(float degrees)
+ => this.AppendCenteredRotationRadians(ImageMaths.DegreesToRadians(degrees));
+
///
/// Prepends a scale matrix from the given uniform scale.
///
diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
index a29342ad46..2f89236544 100644
--- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
+++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
@@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests
using (var blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes))
{
AffineTransformBuilder builder = new AffineTransformBuilder(blend.Size())
- .AppendRotationDegrees(45F)
+ .AppendCenteredRotationDegrees(45F)
.AppendScale(new SizeF(.25F, .25F))
.AppendTranslation(new PointF(10, 10));
diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs
index 639f4b46fa..2a43e56e70 100644
--- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs
@@ -38,11 +38,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
protected override void AppendTranslation(AffineTransformBuilder builder, PointF translate) => builder.AppendTranslation(translate);
protected override void AppendScale(AffineTransformBuilder builder, SizeF scale) => builder.AppendScale(scale);
- protected override void AppendRotationRadians(AffineTransformBuilder builder, float radians) => builder.AppendRotationRadians(radians);
+ protected override void AppendRotationRadians(AffineTransformBuilder builder, float radians) => builder.AppendCenteredRotationRadians(radians);
protected override void PrependTranslation(AffineTransformBuilder builder, PointF translate) => builder.PrependTranslation(translate);
protected override void PrependScale(AffineTransformBuilder builder, SizeF scale) => builder.PrependScale(scale);
- protected override void PrependRotationRadians(AffineTransformBuilder builder, float radians) => builder.PrependRotationRadians(radians);
+ protected override void PrependRotationRadians(AffineTransformBuilder builder, float radians) => builder.PrependCenteredRotationRadians(radians);
protected override Vector2 Execute(
AffineTransformBuilder builder,
diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
index e78bb2c6d9..f86db5641f 100644
--- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
@@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
using (Image image = provider.GetImage())
{
AffineTransformBuilder builder = new AffineTransformBuilder(image.Size())
- .AppendRotationDegrees(30);
+ .AppendCenteredRotationDegrees(30);
image.Mutate(c => c.Transform(builder, resampler));
image.DebugSave(provider, resamplerName);
@@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
image.DebugSave(provider, $"_original");
AffineTransformBuilder builder = new AffineTransformBuilder(image.Size())
- .AppendRotationDegrees(angleDeg)
+ .AppendCenteredRotationDegrees(angleDeg)
.AppendScale(new SizeF(sx, sy))
.AppendTranslation(new PointF(tx, ty));
@@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
using (Image image = provider.GetImage())
{
AffineTransformBuilder builder = new AffineTransformBuilder(image.Size())
- .AppendRotationDegrees(angleDeg)
+ .AppendCenteredRotationDegrees(angleDeg)
.AppendScale(new SizeF(s, s));
image.Mutate(i => i.Transform(builder, KnownResamplers.Bicubic));
@@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
using (Image image = provider.GetImage())
{
AffineTransformBuilder builder = new AffineTransformBuilder(image.Size())
- .AppendRotationDegrees(50)
+ .AppendCenteredRotationDegrees(50)
.AppendScale(new SizeF(.6F, .6F));
image.Mutate(i => i.Transform(builder, sampler));
diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs
index 0d9bd301dc..f467bed40c 100644
--- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs
@@ -34,13 +34,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
var builder = new ProjectiveTransformBuilder(new Rectangle(Point.Empty, s));
});
}
+
protected override void AppendTranslation(ProjectiveTransformBuilder builder, PointF translate) => builder.AppendTranslation(translate);
protected override void AppendScale(ProjectiveTransformBuilder builder, SizeF scale) => builder.AppendScale(scale);
- protected override void AppendRotationRadians(ProjectiveTransformBuilder builder, float radians) => builder.AppendRotationRadians(radians);
+ protected override void AppendRotationRadians(ProjectiveTransformBuilder builder, float radians) => builder.AppendCenteredRotationRadians(radians);
protected override void PrependTranslation(ProjectiveTransformBuilder builder, PointF translate) => builder.PrependTranslation(translate);
protected override void PrependScale(ProjectiveTransformBuilder builder, SizeF scale) => builder.PrependScale(scale);
- protected override void PrependRotationRadians(ProjectiveTransformBuilder builder, float radians) => builder.PrependRotationRadians(radians);
+ protected override void PrependRotationRadians(ProjectiveTransformBuilder builder, float radians) => builder.PrependCenteredRotationRadians(radians);
protected override Vector2 Execute(
ProjectiveTransformBuilder builder,
diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs
index d109387cc4..3f259c9aa2 100644
--- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs
+++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs
@@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
protected abstract void PrependRotationRadians(TBuilder builder, float radians);
protected virtual void AppendRotationDegrees(TBuilder builder, float degrees) =>
- this.AppendRotationRadians(builder, ImageMaths.ToRadian(degrees));
+ this.AppendRotationRadians(builder, ImageMaths.DegreesToRadians(degrees));
protected abstract Vector2 Execute(TBuilder builder, Rectangle rectangle, Vector2 sourcePoint);