• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Transform not quite right
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Transform not quite right
      • From: Henry McGilton <email@hidden>
References: 
 >Transform not quite right (From: David Arnold <email@hidden>)
 >Re: Transform not quite right (From: "R. Matthew Emerson" <email@hidden>)
 >Re: Transform not quite right (From: David Arnold <email@hidden>)

  • Prev by Date: Re: NSDateFormatter and time
  • Next by Date: Re: Transform not quite right
  • Previous by thread: Re: Transform not quite right
  • Next by thread: Re: Transform not quite right
  • Index(es):
    • Date
    • Thread