/* -*- Objc -*- */ /* * $Id: Math.h,v 1.1 2003/05/23 00:22:17 dam Exp $ * * Copyright (C) 2003 Free Software Foundation, Inc. * * This file is part of GNU Hégémonie. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MATH_H #define MATH_H #include #define SWAP(a,b) \ ({typeof(a) _SWAP_aux = (a); \ (a) = (b); (b) = _SWAP_aux; }) #define SQUARE(a) \ ({typeof(a) _SQUARE_a = (a); \ return _SQUARE_a * _SQUARE_a }) #define DEGTORAD(angle) ((angle) * M_PI / 180.0) #define RADTODEG(angle) ((angle) / M_PI * 180.0) /* * MAX and MIN ripped from Gnustep NSGeometry.h */ #ifndef MAX #define MAX(a,b) \ ({typeof(a) _MAX_a = (a); typeof(b) _MAX_b = (b); \ _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) #endif #ifndef MIN #define MIN(a,b) \ ({typeof(a) _MIN_a = (a); typeof(b) _MIN_b = (b); \ _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) #endif #endif /* MATH_H */