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.
|
getNamepublic 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 TransformationTransformation.transform(cse1030.drawing.Point2D)p - the point to transformpublic Point2D apply(Point2D p)
apply in class Transformationtransform(cse1030.drawing.Point2D),
Transformation.apply(cse1030.drawing.Point2D)p - the point to apply the transformation toppublic 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 TransformationTransformation.toString()