//
//  TN+NSAffineTransform.m
//  GraphicsUtilities
//
//  Created by Tommy Nordgren (tommy.nordgren@comhem.se  http://www.tommynordgren.com) on 2008-11-09.
//  Copyright 2008 Tommy Nordgren. All rights reserved.
//

#import "TN+NSAffineTransform.h"


@implementation NSAffineTransform (TNGraphics)

+(NSAffineTransform *) transformRotatedAroundPoint:(NSPoint) p degrees:(CGFloat) deg
{
	NSAffineTransform * trafo = [NSAffineTransform transform];
	[trafo translateXBy: p.x yBy: p.y];
	[trafo rotateByDegrees:deg];
	[trafo translateXBy: -p.x yBy: -p.y];
	return trafo;

}

+(NSAffineTransform *) transformRotatedAroundPoint:(NSPoint) p radians:(CGFloat) rad
{
	NSAffineTransform * trafo = [NSAffineTransform transform];
	[trafo translateXBy: p.x yBy: p.y];
	[trafo rotateByRadians: rad];
	[trafo translateXBy: -p.x yBy: -p.y];
	return trafo;
	
}

+(NSAffineTransform *) transformByTranslatingOriginToPoint:(NSPoint) p
{
	NSAffineTransform * trafo = [NSAffineTransform transform];
	[trafo translateXBy: p.x yBy: p.y];
	return trafo;
}

@end
