• 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
Zooming, Bezier Paths and Affine Transforms
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Zooming, Bezier Paths and Affine Transforms


  • Subject: Zooming, Bezier Paths and Affine Transforms
  • From: Greg <email@hidden>
  • Date: Mon, 27 Dec 2004 17:49:31 +1000

Hi,
I am creating a graph view that allows the user to be able to zoom an area of the x-axis only. This is because a plot can contain up to around 10,000 samples, so to make it easier in viewing areas of the graph I need to be able to zoom areas of it. I am having some trouble trying to display the graph correctly. I can get the correct range of samples to display from the user drawing a box on the graph to zoom it, but when it comes to display it correctly, is where my problems occur.


The steps I am using are to translate to the start of the graph area as there is a margin for axis values and labels. I then translate the x axis to the start of the zoomed samples, (_durationStart). I then scale the X axis by the width and number of zoomed samples (NSWidth(graphBounds) / (_durationEnd - _durationStart)) and the height by the number of values in the Y axis. I then translate the graph by the Y axis minimum value as this might not be set at 0.

I seem to have problems when I use affine transforms as my understanding of them is very limited. I would appreciate it if someone could recommend a book or resource on the net to help me better understand what is happening to the co-ordinate space when I do translations, scales and rotations. Does anyone know what I am doing wrong fundamentally?

Thanks,
Greg

if (_flags.showHeartRate)
{
NSAffineTransform *scale = [NSAffineTransform transform];
NSBezierPath *p = [cur objectForKey:HeartRateKey];
NSRect pathRect = [p bounds];
[scale translateXBy:NSMinX(graphBounds) yBy:NSMinY(graphBounds)];
[scale translateXBy:-_durationStart yBy:0];
[scale scaleXBy:NSWidth(graphBounds) / (_durationEnd - _durationStart)
yBy:NSHeight(graphBounds)/(_heartRateMax - _heartRateMin)];
[scale translateXBy:0 yBy: - _heartRateMin];
[scale concat];
[[_heartRateColor colorWithAlphaComponent:1.0 - (i / (c * 1.0))] set];
[p setLineWidth:_heartRateStroke];
[p stroke];
[scale invert];
[scale concat];
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Zooming, Bezier Paths and Affine Transforms
      • From: Henry McGilton <email@hidden>
  • Prev by Date: Re: NSDecimal localization
  • Next by Date: RE: Cloning an NSTableView which uses bindings
  • Previous by thread: Re: coordinate transformation
  • Next by thread: Re: Zooming, Bezier Paths and Affine Transforms
  • Index(es):
    • Date
    • Thread