bugGNUstep - Bugs: bug #13181, NSAffineTransform order of...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #13181: NSAffineTransform order of operations

Submitted by:  None
Submitted on:  Wed 25 May 2005 06:44:37 AM UTC  
 
Category: Gui/AppKitSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: Adam Fedor <fedor>
Open/Closed: Closed

Fri 27 May 2005 08:48:09 PM UTC, comment #2:

Hard to believe I spelled believe wrong as well...

Anyway, it appears that all the translate/rotate/scale methods were wrong. I changed all of them to use a common matrix multiply function (also to improve readability). The slow down from the function call is not noticable (even without optimization).

Adam Fedor <fedor>
Project AdministratorIn charge of this item.
Thu 26 May 2005 02:33:40 AM UTC, comment #1:

Ugh. Yes. -scaleBy... is wrong. It's hard to beleive we could make a simple math error like that. I'll probably check the other methods as well...

Adam Fedor <fedor>
Project AdministratorIn charge of this item.
Wed 25 May 2005 06:44:37 AM UTC, original submission:

I'm not sure if this is a bug or ignorance. The following bit of code in a graphing application is used to convert data coordinates to screen coordinates:

[toScreenCoordinates release];
toScreenCoordinates = [[NSAffineTransform transform] retain]; // start fresh
// the order of operations is important for matrix algebra!
[toScreenCoordinates scaleXBy: (viewRect.size.width / dataBounds.size.width)
yBy: (viewRect.size.height / dataBounds.size.height)];
[toScreenCoordinates translateXBy: -dataBounds.origin.x
yBy: -dataBounds.origin.y];

It works correctly under OSX but not under GNUstep. The strange part is this: When I swap the last two operations the code behaves identically for OSX and GNUstep, unfortunately it is the undesired behavior. For GNUstep it makes no difference what order the translation and scaling are done, it behaves the same. For OSX, one way does the transform I need and the other does not. (The comment line is a reminder to myself not to get them out of order again.)

The reverse transformation, screen to data, works equally well for both OSX and GNUstep. It requires that the translation be performed before the scaling.

[toDataCoordinates release]; // start fresh
toDataCoordinates = [[NSAffineTransform transform] retain];
[toDataCoordinates translateXBy: dataBounds.origin.x
yBy: dataBounds.origin.y];
[toDataCoordinates scaleXBy: (dataBounds.size.width / viewRect.size.width)
yBy: (dataBounds.size.height / viewRect.size.height)];

Mark Tracy
-unavailable-

Anonymous

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 5 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 27 May 2005 08:48:09 PM UTCfedorStatusIn Progress=>Fixed
  Open/ClosedOpen=>Closed
Thu 26 May 2005 02:33:40 AM UTCfedorCategoryNone=>Gui/AppKit
  StatusNone=>In Progress
  Assigned toNone=>fedor

Back to the top


Powered by Savane 3.1-cleanup1