public class Rotation extends Transformation
Constructor and Description |
---|
Rotation(String name,
double radians)
Construct a rotation transformation given its name and the angle
of rotation in radians.
|
Modifier and Type | Method and Description |
---|---|
Point2D |
apply(Point2D p)
Apply the rotation to a point to produce a new point leaving the
original point unchanged.
|
String |
toString()
Get a string representation of the rotation.
|
void |
transform(Point2D p)
Transform a point changing its coordinates.
|
getName
public Rotation(String name, double radians)
name
- the name of the transformationradians
- the rotation angle in radianspublic void transform(Point2D p)
theta
radians the x
and y
coordinates of the point are transformed as follows:
newx = cos(theta) * x - sin(theta) * y
newy = sin(theta) * x + cos(theta) * y
transform
in class Transformation
Transformation.transform(cse1030.drawing.Point2D)
p
- the point to transformpublic Point2D apply(Point2D p)
apply
in class Transformation
transform(cse1030.drawing.Point2D)
,
Transformation.apply(cse1030.drawing.Point2D)
p
- the point to apply the transformation top
public String toString()
" : rotation of "
followed by the angle in radians followed by the string
" radians"
. For example, a rotation of 90 degrees named
T1
has the following string representation:
"T1 : rotation of 1.5707963267948966 radians"
toString
in class Transformation
Transformation.toString()