Re: Transform not quite right
Re: Transform not quite right
- Subject: Re: Transform not quite right
- From: "R. Matthew Emerson" <email@hidden>
- Date: Sat, 30 Jun 2007 14:44:01 -0400
Unfortunately, when I plot the sine wave in the NSVIew, it starts
at (0,0).
So, you can see that there is something fundamentally wrong with my
thinking.
Think of transformations as operations that move the coordinate
axes. This way, the transformations happen in the order you make them.
If you want to think of transformations as operations that move your
modelled objects, then the transformation declared last applies first.
float xmin = 0.0;
float xmax = 2*pi;
float ymin = -2.0;
float ymax = 2.0;
NSAffineTransform *xForm = [NSAffineTransform transform];
[xForm translateXBy:-xmin yBy:-ymin];
The above line moves your origin up 2 (screen) points. This isn't
what you want: you're translating in terms of the view's default
units (points).
[xForm scaleXBy:(bRect.size.width/(xmax-xmin)) yBy:
(bRect.size.height/(ymax-ymin))];
This is correct. Now, with this scaling performed, do your translation:
[xForm translateXBy:-xmin yBy:-ymin];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden