Basic HTML version of Foils prepared 13 July 98

Foil 61 Another rotate Method

From Java Academy II:Advanced Java NPAC/ECS Java Academy -- February to April 98. by Tom Scavo


1 To rotate a point about the origin: public DrawablePoint rotate( double theta ) { final double cos_t = Math.cos( theta ); final double sin_t = Math.sin( theta ); double x_double, y_double; x_double = this.x*cos_t - this.y*sin_t; y_double = this.x*sin_t + this.y*cos_t; int new_x = ( int ) Math.round( x_double ); int new_y = ( int ) Math.round( y_double ); this.move( new_x, new_y ); return this; }

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998