Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 8:28 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Vector2f bug
PostPosted: Mon May 04, 2009 10:36 pm 
Offline

Joined: Mon May 04, 2009 10:19 pm
Posts: 4
There's a bug in Vector2f.setTheta(double)

The following
Code:
Log.debug("" + new Vector2f(91.4155775494873524));
Log.debug("" + new Vector2f(91.4155775494873524).getTheta());

gives me
Code:
Mon May 04 18:29:06 EDT 2009 DEBUG:[Vector2f 0.024703976,0.9996948 (1.0)]
Mon May 04 18:29:06 EDT 2009 DEBUG:88.58442246164603


The problem is line 56 of Vector2f that says
Code:
x = -len * (float) FastTrig.cos(StrictMath.toRadians(theta));

and instead should just be
Code:
x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 05, 2009 7:26 am 
Offline
Regular

Joined: Tue Jun 19, 2007 7:35 am
Posts: 233
Location: Germany
why not this?

Code:
void rotate(float rad) {
   float cos = cos(rad);
   float sin = sin(rad);
   float tx = (x * cos) - (y * sin);
   float ty = (x * sin) + (y * cos);
   x = tx;
   y = ty;
}


here you don't need length (expensive sqrt).

_________________
Embero Games | Astroiz | ConK | From Outa Space


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 24, 2009 12:48 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Resolved in SVN.

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group