ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/objcX-0.87.tgz#/objcX-0.87/dpsclient/cgt.h

This is cgt.h in view mode; [Download] [Up]

/* cgt - Functions to deal with CGT matrices

   Copyright (C) 1995 Free Software Foundation, Inc.

   Written by:  Adam Fedor <fedor@boulder.colorado.edu>
   Date: Nov 1995
   
   This file is part of the GNU Objective C User interface library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   */

#ifndef _cgt_h_INCLUDE
#define _cgt_h_INCLUDE

#include <Foundation/NSGeometry.h>

/* 
    Homogenous coordinate geometric transform matrix
	[ a  b  0 ]
    T = [ c  d  0 ]
	[ tx ty 1 ]
    Transform a point by pre-multiplying the point by the matrix, i.e.
    	Pnew = transpose(P) * T
*/
typedef struct {
    double  a, b, c, d, tx, ty;
} cgt_t;

/* Useful functions to deal with CGT matrices. Rotation is specified
   in degrees.
	concatCGT  - concatenates two CGTs, acgt and bcgt, and
	returns the new matrix. (cgt = acgt * bcgt)

	composeCGT - Compose a CGT matrix from the 
	specified scale, translation, and rotation. The transformation is
	applied in the order that the arguments are given (i.e. scale, 
	then rotate, then translate). Arguments are given as pointers to make
	it easy to generate an identity transform matrix - use
	composeCGT(NULL, 0, NULL) to generate a matrix with no translation
	or rotation and a scaling of one.
	
	decomposeCGT - Return the transfomation information that was used to
	construct the CGT (via a call to composeCGT).
	
	applyCGT - Transforms the point by the given CGT. Returns the new 
	point.
*/
extern cgt_t	concatCGT(cgt_t acgt, cgt_t bcgt);
extern cgt_t	composeCGT(const NSSize *scale, double rotation, 
		const NSPoint *trans);
extern void	decomposeCGT(cgt_t cgt, NSSize *scale, double *rotation,
		NSPoint *trans);
extern cgt_t	invertCGT(cgt_t cgt);

extern NSPoint  applyCGT(NSPoint point, cgt_t cgt);
extern double	rotationFromCGT(cgt_t cgt);
extern NSSize	scaleFromCGT(cgt_t cgt);
extern NSPoint	offsetFromCGT(cgt_t cgt);

extern const float *  cgtToMatrix(cgt_t cgt);
extern cgt_t    matrixToCgt(const float *m);
#endif

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.