• 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
Images spinning in my head....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Images spinning in my head....


  • Subject: Images spinning in my head....
  • From: Jerry LeVan <email@hidden>
  • Date: Fri, 2 Jul 2004 19:54:44 -0400

Consider: ( with rotateFactor = 90, clockwise rotation) and I have
an image with size = (scaledRect.width, scaledRect.height) and I
want to rotate the rascal 90 degrees clockwise. Imagine the image
as being a couple of times "wider" than "higher".

[imageRotation rotateByDegrees:-rotateFactor];
[tmpT translateXBy:0.0 yBy:scaledRect.width];
[imageRotation appendTransform: tmpT];
curr = [imageRotation transformStruct];
NSLog(@"clockwise:%f ,%f ,%f ,%f ,%f ,%f ",curr.m11,curr.m12,curr.m21,curr.m22,curr.tX,curr.tY);

and

[imageRotation rotateByDegrees:-rotateFactor];
[imageRotation translateXBy:-scaledRect.width yBy:0];
curr = [imageRotation transformStruct];
NSLog(@"clockwise:%f ,%f ,%f ,%f ,%f ,%f ",curr.m11,curr.m12,curr.m21,curr.m22,curr.tX,curr.tY);

followed a little later by

[imageRotation concat];
[ tmpImage drawAtPoint:NSMakePoint(0,0) fromRect:NSMakeRect(0,0, scaledRect.width, scaledRect.height) operation:NSCompositeCopy fraction:1.0];

Both of the NSLogs reveal that the both values of imageRotation are the same.
In addition they "draw" the same image (the original image rotated 90 c.w.).

Notice the asymmetry in the translateXBy parts...

I am having a little trouble getting my mind around the
differences between the two methods and how I should be
visualizing what is going on.

Here is my current working theory
For the first transformation

************** (w,h)
* |
(0,0)**************
1) [imageRotation rotateByDegrees:-90] This rotates the rectangle representing
the image 90 degrees clockwise and it is now pointing down

(0,0)* * *
* *
* *
* *
* - * (h,-w) <- with respect to the original co-ordinate system

2) I need to translate all of the "points" *Up* w points,
the transformation: [tmpT translateXBy:0.0 yBy:scaledRect.width];
does just that, the *composition* of the two transforms should be used.

* * * (h,w) <- with respect to the original co-ordinate system
* *
* *
* *
(0,0) * - *


In short I keep looking at the *original* co-ordinate system to try to decide
what to do next and compose with the previous transforms.

Let's look at the second transform:

Start:

************** (w,h)
* |
(0,0)**************

Again I want to do the rotation just as before.
1) [imageRotation rotateByDegrees:-90] This rotates the rectangle representing
the image 90 degrees clockwise and it is now pointing down

(0,0)* * *
* *
* *
* *
* - * (w,h)
2) Here I need to consider the x-axis as pointing *down* in the above picture.
ie positive x grows down.

I want to push the points in the image so that (0,0) is the lower left.
I have to *subtract* w from each of the x coordinates
ie
[imageRotation translateXBy:-scaledRect.width yBy:0];

* * * (-w,h)
* *
* *
* *
(0,0) * - * (0,h)

When I look at the above in the *original* coordinate system
I have exactly what I want.

ie In the case where you write a sequence of transformations as opposed
to a composition of transformations. Consider the new co-ordinate system
each time you try to decide what to do next and write your transform with
respect to the new coordinate system.

Does this make any sense :)

Side question, are a sequence of transformations or composition of
transformations calculated only once? Is there only one transform
applied or is each applied.

Thanks,

Jerry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: [GENERAL] COPY command with blank incoming values
  • Next by Date: Re: Draggable Tags?
  • Previous by thread: Re: Draggable Tags?
  • Next by thread: Re: Mixing Objective-C and C++ in Xcode - Example
  • Index(es):
    • Date
    • Thread