# Java Algorithms How to - Find Angle from transform matrix

## Question

We would like to know how to find Angle from transform matrix.

```import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.util.Random;
//from  w  w  w.jav  a 2s  .  c  o m
public class Main {
public static void main(String[] args) {
for (int i = 0; i <= 180; i++) {
System.out.println("In: " + Math.toDegrees(angleRad) + " " + "Out "
}
}
private static double extractAngle(AffineTransform at) {
Point2D p0 = new Point();
Point2D p1 = new Point(1, 0);
Point2D pp0 = at.transform(p0, null);
Point2D pp1 = at.transform(p1, null);
double dx = pp1.getX() - pp0.getX();
double dy = pp1.getY() - pp0.getY();
double angle = Math.atan2(dy, dx);
return angle;
}

private static AffineTransform createRandomTransform(double angleRad) {
AffineTransform at = new AffineTransform();
double scale = 1.0;
at.translate(randomDouble(), randomDouble());
scale = Math.abs(randomDouble());
at.scale(scale, scale);