• 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: Henry McGilton <email@hidden>
  • Date: Sat, 30 Jun 2007 11:56:54 -0700


On Jun 30, 2007, at 11:44 AM, R. Matthew Emerson wrote:

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];

Also (unless you *really* want to plot curves 'by hand --- maybe for pedagogical purposes), you might consider letting the underlying graphics system do the work by defining your curves in terms of Cubic Bezier curves. Here is a useful reference:

    <http://www.tinaja.com/glib/bezsine.pdf>

    Cheers,
        ........  Henry


===============================+============================ Henry McGilton, Boulevardier | Trilithon Software Objective-C/Java Composer | Seroia Research -------------------------------+---------------------------- mailto:email@hidden | http://www.trilithon.com | ===============================+============================




_______________________________________________

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


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>)
 >Re: Transform not quite right (From: "R. Matthew Emerson" <email@hidden>)

  • Prev by Date: Re: Transform not quite right
  • Next by Date: Function from string
  • Previous by thread: Re: Transform not quite right
  • Next by thread: ScreenSaver Shell?
  • Index(es):
    • Date
    • Thread