X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsupport%2Fnormangle.cpp;fp=libctsupport%2Fnormangle.cpp;h=b04ee93fc4e8ca8ef374620b9e8d6a804720801f;hp=0000000000000000000000000000000000000000;hb=99dd1d6ed10db1f669a5fe6af71225a50fc0ddfb;hpb=2c61ff85796550481227f2fbec53506a6b5bd365 diff --git a/libctsupport/normangle.cpp b/libctsupport/normangle.cpp new file mode 100644 index 0000000..b04ee93 --- /dev/null +++ b/libctsupport/normangle.cpp @@ -0,0 +1,42 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: normangle.cpp,v 1.1 2000/06/19 02:58:08 kevin Exp $ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ + +#include "kmath.h" + + +/* NAME + * norm_ang Normalize angle to 0 to 2 * PI range + * + * SYNOPSIS + * t = norm_ang (theta) + * double t Normalized angle + * double theta Input angle + */ + +double +norm_ang (double theta) +{ + while (theta < 0.) + theta += TWOPI; + while (theta >= TWOPI) + theta -= TWOPI; + + return (theta); +}