From: curt Date: Wed, 8 Apr 1998 23:19:34 +0000 (+0000) Subject: Adopted Gnu automake/autoconf system. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=784960bd8f123ffc78b49d950b0fd18cdfd7dcd5;p=flightgear.git Adopted Gnu automake/autoconf system. --- diff --git a/FixObj/MAT3vec.c b/FixObj/MAT3vec.c new file mode 100644 index 000000000..24f2939af --- /dev/null +++ b/FixObj/MAT3vec.c @@ -0,0 +1,149 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* -------------------------------------------------------------------------- + * This file contains routines that operate on matrices and vectors, or + * vectors and vectors. + * -------------------------------------------------------------------------*/ + +/* #include "sphigslocal.h" */ + +/* -------------------------- Static Routines ---------------------------- */ + +/* ------------------------- Internal Routines --------------------------- */ + +/* -------------------------- Public Routines ---------------------------- */ + +/* + * Multiplies a vector by a matrix, setting the result vector. + * It assumes all homogeneous coordinates are 1. + * The two vectors involved may be the same. + */ + +#include + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + + +void +MAT3mult_vec(double *result_vec, register double *vec, register double (*mat)[4]) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + mat[3][2]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Multiplies a vector of size 4 by a matrix, setting the result vector. + * The fourth element of the vector is the homogeneous coordinate, which + * may or may not be 1. If the "normalize" parameter is TRUE, then the + * result vector will be normalized so that the homogeneous coordinate is 1. + * The two vectors involved may be the same. + * This returns zero if the vector was to be normalized, but couldn't be. + */ + +int +MAT3mult_hvec(double *result_vec, register double *vec, register double (*mat)[4], int normalize) +{ + MAT3hvec tempvec; + double norm_fac; + register double *temp = tempvec; + register int ret = TRUE; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + vec[3] * mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + vec[3] * mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + vec[3] * mat[3][2]; + temp[3] = vec[0] * mat[0][3] + vec[1] * mat[1][3] + + vec[2] * mat[2][3] + vec[3] * mat[3][3]; + + /* Normalize if asked for, possible, and necessary */ + if (normalize) { + if (MAT3_IS_ZERO(temp[3])) { +#ifndef THINK_C + fprintf (stderr, + "Can't normalize vector: homogeneous coordinate is 0"); +#endif + ret = FALSE; + } + else { + norm_fac = 1.0 / temp[3]; + MAT3_SCALE_VEC(result_vec, temp, norm_fac); + result_vec[3] = 1.0; + } + } + else MAT3_COPY_HVEC(result_vec, temp); + + return(ret); +} + +/* + * Sets the first vector to be the cross-product of the last two vectors. + */ + +void +MAT3cross_product(double *result_vec, register double *vec1, register double *vec2) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; + temp[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; + temp[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Finds a vector perpendicular to vec and stores it in result_vec. + * Method: take any vector (we use <0,1,0>) and subtract the + * portion of it pointing in the vec direction. This doesn't + * work if vec IS <0,1,0> or is very near it. So if this is + * the case, use <0,0,1> instead. + * If "is_unit" is TRUE, the given vector is assumed to be unit length. + */ + +#define SELECT .7071 /* selection constant (roughly .5*sqrt(2) */ + +void +MAT3perp_vec(double *result_vec, double *vec, int is_unit) +{ + MAT3vec norm; + double dot; + + MAT3_SET_VEC(result_vec, 0.0, 1.0, 0.0); + + MAT3_COPY_VEC(norm, vec); + + if (! is_unit) MAT3_NORMALIZE_VEC(norm, dot); + + /* See if vector is too close to <0,1,0>. If so, use <0,0,1> */ + if ((dot = MAT3_DOT_PRODUCT(norm, result_vec)) > SELECT || dot < -SELECT) { + result_vec[1] = 0.0; + result_vec[2] = 1.0; + dot = MAT3_DOT_PRODUCT(norm, result_vec); + } + + /* Subtract off non-perpendicular part */ + result_vec[0] -= dot * norm[0]; + result_vec[1] -= dot * norm[1]; + result_vec[2] -= dot * norm[2]; + + /* Make result unit length */ + MAT3_NORMALIZE_VEC(result_vec, dot); +} diff --git a/FixObj/Makefile b/FixObj/Makefile deleted file mode 100644 index 64a5bc17d..000000000 --- a/FixObj/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -#--------------------------------------------------------------------------- -# Makefile -# -# Written by Curtis Olson, started October 1997. -# -# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# $Id$ -# (Log is kept at end of this file) -#--------------------------------------------------------------------------- - - -TARGET = fixobj - -CFILES = main.c obj.c -LDLIBS = -lMath -lm - - -include $(FG_ROOT_SRC)/commondefs - - -#--------------------------------------------------------------------------- -# Rule for TARGET -#--------------------------------------------------------------------------- - -$(TARGET): $(OBJECTS) - $(CC) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(LDLIBS) - - -include $(COMMONRULES) - - -#--------------------------------------------------------------------------- -# $Log$ -# Revision 1.2 1998/01/21 02:55:53 curt -# Incorporated new make system from Bob Kuehne . -# -# Revision 1.1 1997/12/08 19:28:54 curt -# Initial revision. -# diff --git a/FixObj/Makefile.am b/FixObj/Makefile.am new file mode 100644 index 000000000..3e33b5d82 --- /dev/null +++ b/FixObj/Makefile.am @@ -0,0 +1,46 @@ +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started October 1997. +# +# Copyright (C) 1997 - 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +bin_PROGRAMS = fixobj + +fixobj_SOURCES = main.c mat3.h obj.c obj.h MAT3vec.c + +fixobj_LDADD = + +INCLUDES += -I../../Simulator + + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:19:35 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.2 1998/01/21 02:55:53 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.1 1997/12/08 19:28:54 curt +# Initial revision. +# diff --git a/FixObj/Makefile.in b/FixObj/Makefile.in new file mode 100644 index 000000000..6c2a3683e --- /dev/null +++ b/FixObj/Makefile.in @@ -0,0 +1,358 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started October 1997. +# +# Copyright (C) 1997 - 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +bin_PROGRAMS = fixobj + +fixobj_SOURCES = main.c mat3.h obj.c obj.h MAT3vec.c + +fixobj_LDADD = +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../Simulator/Include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +fixobj_OBJECTS = main.o obj.o MAT3vec.o +fixobj_DEPENDENCIES = +fixobj_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/MAT3vec.P .deps/main.P .deps/obj.P +SOURCES = $(fixobj_SOURCES) +OBJECTS = $(fixobj_OBJECTS) + +all: Makefile $(PROGRAMS) + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Tools/FixObj/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +fixobj: $(fixobj_OBJECTS) $(fixobj_DEPENDENCIES) + @rm -f fixobj + $(LINK) $(fixobj_LDFLAGS) $(fixobj_OBJECTS) $(fixobj_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Tools/FixObj + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Tools/FixObj/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binPROGRAMS + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +clean: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean + +distclean: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-libtool maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info dvi installcheck install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +INCLUDES += -I../../Simulator + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:19:36 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.2 1998/01/21 02:55:53 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.1 1997/12/08 19:28:54 curt +# Initial revision. +# + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/FixObj/mat3.h b/FixObj/mat3.h new file mode 100644 index 000000000..58c4b9e07 --- /dev/null +++ b/FixObj/mat3.h @@ -0,0 +1,147 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* ------------------------------------------------------------------------- + Public MAT3 include file + ------------------------------------------------------------------------- */ + +#ifndef MAT3_HAS_BEEN_INCLUDED +#define MAT3_HAS_BEEN_INCLUDED + +/* ----------------------------- Constants ------------------------------ */ + +/* + * Make sure the math library .h file is included, in case it wasn't. + */ + +#ifndef HUGE +#include +#endif +#include + + +#define MAT3_DET0 -1 /* Indicates singular mat */ +#define MAT3_EPSILON 1e-12 /* Close enough to zero */ +#define MAT3_PI 3.141592653589793 /* Pi */ + +/* ------------------------------ Types --------------------------------- */ + +typedef double MAT3mat[4][4]; /* 4x4 matrix */ +typedef double MAT3vec[3]; /* Vector */ +typedef double MAT3hvec[4]; /* Vector with homogeneous coord */ + +/* ------------------------------ Macros -------------------------------- */ + +/* Tests if a number is within EPSILON of zero */ +#define MAT3_IS_ZERO(N) ((N) < MAT3_EPSILON && (N) > -MAT3_EPSILON) + +/* Sets a vector to the three given values */ +#define MAT3_SET_VEC(V,X,Y,Z) ((V)[0]=(X), (V)[1]=(Y), (V)[2]=(Z)) + +/* Tests a vector for all components close to zero */ +#define MAT3_IS_ZERO_VEC(V) (MAT3_IS_ZERO((V)[0]) && \ + MAT3_IS_ZERO((V)[1]) && \ + MAT3_IS_ZERO((V)[2])) + +/* Dot product of two vectors */ +#define MAT3_DOT_PRODUCT(V1,V2) \ + ((V1)[0]*(V2)[0] + (V1)[1]*(V2)[1] + (V1)[2]*(V2)[2]) + +/* Copy one vector to other */ +#define MAT3_COPY_VEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2]) + +/* Normalize vector to unit length, using TEMP as temporary variable. + * TEMP will be zero if vector has zero length */ +#define MAT3_NORMALIZE_VEC(V,TEMP) \ + if ((TEMP = sqrt(MAT3_DOT_PRODUCT(V,V))) > MAT3_EPSILON) { \ + TEMP = 1.0 / TEMP; \ + MAT3_SCALE_VEC(V,V,TEMP); \ + } else TEMP = 0.0 + +/* Scale vector by given factor, storing result vector in RESULT_V */ +#define MAT3_SCALE_VEC(RESULT_V,V,SCALE) \ + MAT3_SET_VEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), (V)[2]*(SCALE)) + +/* Adds vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_ADD_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2]) + +/* Subtracts vector V2 from V1, storing result in RESULT_V */ +#define MAT3_SUB_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2]) + +/* Multiplies vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_MULT_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2]) + +/* Sets RESULT_V to the linear combination of V1 and V2, scaled by + * SCALE1 and SCALE2, respectively */ +#define MAT3_LINEAR_COMB(RESULT_V,SCALE1,V1,SCALE2,V2) \ + MAT3_SET_VEC(RESULT_V, (SCALE1)*(V1)[0] + (SCALE2)*(V2)[0], \ + (SCALE1)*(V1)[1] + (SCALE2)*(V2)[1], \ + (SCALE1)*(V1)[2] + (SCALE2)*(V2)[2]) + +/* Several of the vector macros are useful for homogeneous-coord vectors */ +#define MAT3_SET_HVEC(V,X,Y,Z,W) ((V)[0]=(X), (V)[1]=(Y), \ + (V)[2]=(Z), (V)[3]=(W)) + +#define MAT3_COPY_HVEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2], \ + (TO)[3] = (FROM)[3]) + +#define MAT3_SCALE_HVEC(RESULT_V,V,SCALE) \ + MAT3_SET_HVEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), \ + (V)[2]*(SCALE), (V)[3]*(SCALE)) + +#define MAT3_ADD_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2], (V1)[3]+(V2)[3]) + +#define MAT3_SUB_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2], (V1)[3]-(V2)[3]) + +#define MAT3_MULT_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2], (V1)[3]*(V2)[3]) + +/* ------------------------------ Entries ------------------------------- */ + + +/* In MAT3geom.c */ +void MAT3direction_matrix (MAT3mat result_mat, MAT3mat mat); +int MAT3normal_matrix (MAT3mat result_mat, MAT3mat mat); +void MAT3rotate (MAT3mat result_mat, MAT3vec axis, double angle_in_radians); +void MAT3translate (MAT3mat result_mat, MAT3vec trans); +void MAT3scale (MAT3mat result_mat, MAT3vec scale); +void MAT3shear(MAT3mat result_mat, double xshear, double yshear); + +/* In MAT3mat.c */ +void MAT3identity(MAT3mat); +void MAT3zero(MAT3mat); +void MAT3copy (MAT3mat to, MAT3mat from); +void MAT3mult (MAT3mat result, MAT3mat, MAT3mat); +void MAT3transpose (MAT3mat result, MAT3mat); +int MAT3invert (MAT3mat result, MAT3mat); +void MAT3print (MAT3mat, FILE *fp); +void MAT3print_formatted (MAT3mat, FILE *fp, + char *title, char *head, char *format, char *tail); +extern int MAT3equal( void ); +extern double MAT3trace( void ); +extern int MAT3power( void ); +extern int MAT3column_reduce( void ); +extern int MAT3kernel_basis( void ); + +/* In MAT3vec.c */ +void MAT3mult_vec(MAT3vec result_vec, MAT3vec vec, MAT3mat mat); +int MAT3mult_hvec (MAT3hvec result_vec, MAT3hvec vec, MAT3mat mat, int normalize); +void MAT3cross_product(MAT3vec result,MAT3vec,MAT3vec); +void MAT3perp_vec(MAT3vec result_vec, MAT3vec vec, int is_unit); + +#endif /* MAT3_HAS_BEEN_INCLUDED */ + diff --git a/FixObj/obj.c b/FixObj/obj.c index 8d2deceb8..9fec7f7e6 100644 --- a/FixObj/obj.c +++ b/FixObj/obj.c @@ -29,7 +29,7 @@ #include "obj.h" -#include "../../Src/Math/mat3.h" +#include "mat3.h" /* what do ya' know, here's some global variables */ @@ -291,9 +291,12 @@ void obj_fix(char *infile, char *outfile) { /* $Log$ -/* Revision 1.7 1998/03/19 02:51:41 curt -/* Added special case handling to compensate for bugs in our beloved tri striper +/* Revision 1.8 1998/04/08 23:19:37 curt +/* Adopted Gnu automake/autoconf system. /* + * Revision 1.7 1998/03/19 02:51:41 curt + * Added special case handling to compensate for bugs in our beloved tri striper + * * Revision 1.6 1998/03/03 15:36:12 curt * Tweaks for compiling with g++ * diff --git a/SplitTris/MAT3vec.c b/SplitTris/MAT3vec.c new file mode 100644 index 000000000..24f2939af --- /dev/null +++ b/SplitTris/MAT3vec.c @@ -0,0 +1,149 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* -------------------------------------------------------------------------- + * This file contains routines that operate on matrices and vectors, or + * vectors and vectors. + * -------------------------------------------------------------------------*/ + +/* #include "sphigslocal.h" */ + +/* -------------------------- Static Routines ---------------------------- */ + +/* ------------------------- Internal Routines --------------------------- */ + +/* -------------------------- Public Routines ---------------------------- */ + +/* + * Multiplies a vector by a matrix, setting the result vector. + * It assumes all homogeneous coordinates are 1. + * The two vectors involved may be the same. + */ + +#include + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + + +void +MAT3mult_vec(double *result_vec, register double *vec, register double (*mat)[4]) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + mat[3][2]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Multiplies a vector of size 4 by a matrix, setting the result vector. + * The fourth element of the vector is the homogeneous coordinate, which + * may or may not be 1. If the "normalize" parameter is TRUE, then the + * result vector will be normalized so that the homogeneous coordinate is 1. + * The two vectors involved may be the same. + * This returns zero if the vector was to be normalized, but couldn't be. + */ + +int +MAT3mult_hvec(double *result_vec, register double *vec, register double (*mat)[4], int normalize) +{ + MAT3hvec tempvec; + double norm_fac; + register double *temp = tempvec; + register int ret = TRUE; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + vec[3] * mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + vec[3] * mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + vec[3] * mat[3][2]; + temp[3] = vec[0] * mat[0][3] + vec[1] * mat[1][3] + + vec[2] * mat[2][3] + vec[3] * mat[3][3]; + + /* Normalize if asked for, possible, and necessary */ + if (normalize) { + if (MAT3_IS_ZERO(temp[3])) { +#ifndef THINK_C + fprintf (stderr, + "Can't normalize vector: homogeneous coordinate is 0"); +#endif + ret = FALSE; + } + else { + norm_fac = 1.0 / temp[3]; + MAT3_SCALE_VEC(result_vec, temp, norm_fac); + result_vec[3] = 1.0; + } + } + else MAT3_COPY_HVEC(result_vec, temp); + + return(ret); +} + +/* + * Sets the first vector to be the cross-product of the last two vectors. + */ + +void +MAT3cross_product(double *result_vec, register double *vec1, register double *vec2) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; + temp[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; + temp[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Finds a vector perpendicular to vec and stores it in result_vec. + * Method: take any vector (we use <0,1,0>) and subtract the + * portion of it pointing in the vec direction. This doesn't + * work if vec IS <0,1,0> or is very near it. So if this is + * the case, use <0,0,1> instead. + * If "is_unit" is TRUE, the given vector is assumed to be unit length. + */ + +#define SELECT .7071 /* selection constant (roughly .5*sqrt(2) */ + +void +MAT3perp_vec(double *result_vec, double *vec, int is_unit) +{ + MAT3vec norm; + double dot; + + MAT3_SET_VEC(result_vec, 0.0, 1.0, 0.0); + + MAT3_COPY_VEC(norm, vec); + + if (! is_unit) MAT3_NORMALIZE_VEC(norm, dot); + + /* See if vector is too close to <0,1,0>. If so, use <0,0,1> */ + if ((dot = MAT3_DOT_PRODUCT(norm, result_vec)) > SELECT || dot < -SELECT) { + result_vec[1] = 0.0; + result_vec[2] = 1.0; + dot = MAT3_DOT_PRODUCT(norm, result_vec); + } + + /* Subtract off non-perpendicular part */ + result_vec[0] -= dot * norm[0]; + result_vec[1] -= dot * norm[1]; + result_vec[2] -= dot * norm[2]; + + /* Make result unit length */ + MAT3_NORMALIZE_VEC(result_vec, dot); +} diff --git a/SplitTris/Makefile b/SplitTris/Makefile deleted file mode 100644 index 27313a425..000000000 --- a/SplitTris/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -#--------------------------------------------------------------------------- -# Makefile -# -# Written by Curtis Olson, started January 1998. -# -# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# $Id$ -# (Log is kept at end of this file) -#--------------------------------------------------------------------------- - - -TARGET = splittris - -CFILES = splittris.c -LDLIBS = -lMath -lScenery -lm - - -include $(FG_ROOT_SRC)/commondefs - - -#--------------------------------------------------------------------------- -# Rule for TARGET -#--------------------------------------------------------------------------- - -$(TARGET): $(OBJECTS) - $(CC) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(LDLIBS) - - -include $(COMMONRULES) - - -#--------------------------------------------------------------------------- -# $Log$ -# Revision 1.3 1998/01/21 02:55:55 curt -# Incorporated new make system from Bob Kuehne . -# -# Revision 1.2 1998/01/14 15:54:42 curt -# Initial revision completed. -# -# Revision 1.1 1998/01/14 02:11:30 curt -# Initial revision. -# diff --git a/SplitTris/Makefile.am b/SplitTris/Makefile.am new file mode 100644 index 000000000..ca10cc328 --- /dev/null +++ b/SplitTris/Makefile.am @@ -0,0 +1,55 @@ +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started January 1998. +# +# Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +bin_PROGRAMS = splittris + +splittris_SOURCES = \ + MAT3vec.c \ + fg_geodesy.c fg_geodesy.h \ + mat3.h \ + polar.c polar.h \ + splittris.c splittris.h + +splittris_LDADD = \ + $(top_builddir)/Simulator/Scenery/Bucket/libBucket.la + +INCLUDES += -I../../Simulator + + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:21:10 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.3 1998/01/21 02:55:55 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.2 1998/01/14 15:54:42 curt +# Initial revision completed. +# +# Revision 1.1 1998/01/14 02:11:30 curt +# Initial revision. +# diff --git a/SplitTris/Makefile.in b/SplitTris/Makefile.in new file mode 100644 index 000000000..7eab72fae --- /dev/null +++ b/SplitTris/Makefile.in @@ -0,0 +1,369 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started January 1998. +# +# Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +bin_PROGRAMS = splittris + +splittris_SOURCES = \ + MAT3vec.c \ + fg_geodesy.c fg_geodesy.h \ + mat3.h \ + polar.c polar.h \ + splittris.c splittris.h + +splittris_LDADD = \ + $(top_builddir)/Simulator/Scenery/Bucket/libBucket.la +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../Simulator/Include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +splittris_OBJECTS = MAT3vec.o fg_geodesy.o polar.o splittris.o +splittris_DEPENDENCIES = \ +$(top_builddir)/Simulator/Scenery/Bucket/libBucket.la +splittris_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/MAT3vec.P .deps/fg_geodesy.P .deps/polar.P \ +.deps/splittris.P +SOURCES = $(splittris_SOURCES) +OBJECTS = $(splittris_OBJECTS) + +all: Makefile $(PROGRAMS) + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Tools/SplitTris/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +splittris: $(splittris_OBJECTS) $(splittris_DEPENDENCIES) + @rm -f splittris + $(LINK) $(splittris_LDFLAGS) $(splittris_OBJECTS) $(splittris_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Tools/SplitTris + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Tools/SplitTris/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binPROGRAMS + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +clean: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean + +distclean: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-libtool maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info dvi installcheck install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +INCLUDES += -I../../Simulator + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:21:11 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.3 1998/01/21 02:55:55 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.2 1998/01/14 15:54:42 curt +# Initial revision completed. +# +# Revision 1.1 1998/01/14 02:11:30 curt +# Initial revision. +# + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/SplitTris/fg_geodesy.c b/SplitTris/fg_geodesy.c new file mode 100644 index 000000000..773010375 --- /dev/null +++ b/SplitTris/fg_geodesy.c @@ -0,0 +1,230 @@ +/************************************************************************** + * fg_geodesy.c -- routines to convert between geodetic and geocentric + * coordinate systems. + * + * Copied and adapted directly from LaRCsim/ls_geodesy.c + * + * See below for the complete original LaRCsim comments. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#include + +#include + +#include "fg_geodesy.h" + + +/* ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator */ +#define ONE_SECOND 4.848136811E-6 + + +/* fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) + * INPUTS: + * lat_geoc Geocentric latitude, radians, + = North + * radius C.G. radius to earth center, ft + * + * OUTPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * sea_level_r radius from earth center to sea level at + * local vertical (surface normal) of C.G. + */ + +void fgGeocToGeod( double lat_geoc, double radius, double + *lat_geod, double *alt, double *sea_level_r ) +{ + double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha; + double sin_mu_a, denom,delt_lambda, lambda_sl, sin_lambda_sl; + + if( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) /* near North pole */ + || ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) /* near South pole */ + { + *lat_geod = lat_geoc; + *sea_level_r = EQUATORIAL_RADIUS_KM*E; + *alt = radius - *sea_level_r; + } else { + t_lat = tan(lat_geoc); + x_alpha = E*EQUATORIAL_RADIUS_KM/sqrt(t_lat*t_lat + E*E); + mu_alpha = atan2(sqrt(RESQ_KM - x_alpha*x_alpha),E*x_alpha); + if (lat_geoc < 0) mu_alpha = - mu_alpha; + sin_mu_a = sin(mu_alpha); + delt_lambda = mu_alpha - lat_geoc; + r_alpha = x_alpha/cos(lat_geoc); + l_point = radius - r_alpha; + *alt = l_point*cos(delt_lambda); + denom = sqrt(1-EPS*EPS*sin_mu_a*sin_mu_a); + rho_alpha = EQUATORIAL_RADIUS_KM*(1-EPS)/ + (denom*denom*denom); + delt_mu = atan2(l_point*sin(delt_lambda),rho_alpha + *alt); + *lat_geod = mu_alpha - delt_mu; + lambda_sl = atan( E*E * tan(*lat_geod) ); /* SL geoc. latitude */ + sin_lambda_sl = sin( lambda_sl ); + *sea_level_r = + sqrt(RESQ_KM / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl)); + } +} + + +/* fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) + * INPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * + * OUTPUTS: + * sl_radius SEA LEVEL radius to earth center, ft (add Altitude to + * get true distance from earth center. + * lat_geoc Geocentric latitude, radians, + = North + * + */ + +void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, + double *lat_geoc ) +{ + double lambda_sl, sin_lambda_sl, cos_lambda_sl, sin_mu, cos_mu, px, py; + + lambda_sl = atan( E*E * tan(lat_geod) ); /* sea level geocentric latitude */ + sin_lambda_sl = sin( lambda_sl ); + cos_lambda_sl = cos( lambda_sl ); + sin_mu = sin(lat_geod); /* Geodetic (map makers') latitude */ + cos_mu = cos(lat_geod); + *sl_radius = + sqrt(RESQ_KM / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl)); + py = *sl_radius*sin_lambda_sl + alt*sin_mu; + px = *sl_radius*cos_lambda_sl + alt*cos_mu; + *lat_geoc = atan2( py, px ); +} + + +/*************************************************************************** + + TITLE: ls_geodesy + +---------------------------------------------------------------------------- + + FUNCTION: Converts geocentric coordinates to geodetic positions + +---------------------------------------------------------------------------- + + MODULE STATUS: developmental + +---------------------------------------------------------------------------- + + GENEALOGY: Written as part of LaRCSim project by E. B. Jackson + +---------------------------------------------------------------------------- + + DESIGNED BY: E. B. Jackson + + CODED BY: E. B. Jackson + + MAINTAINED BY: E. B. Jackson + +---------------------------------------------------------------------------- + + MODIFICATION HISTORY: + + DATE PURPOSE BY + + 930208 Modified to avoid singularity near polar region. EBJ + 930602 Moved backwards calcs here from ls_step. EBJ + 931214 Changed erroneous Latitude and Altitude variables to + *lat_geod and *alt in routine ls_geoc_to_geod. EBJ + 940111 Changed header files from old ls_eom.h style to ls_types, + and ls_constants. Also replaced old DATA type with new + SCALAR type. EBJ + + CURRENT RCS HEADER: + +$Header$ +$Log$ +Revision 1.1 1998/04/08 23:21:11 curt +Adopted Gnu automake/autoconf system. + +Revision 1.4 1998/01/27 00:47:59 curt +Incorporated Paul Bleisch's new debug message +system and commandline/config file processing code. + +Revision 1.3 1998/01/19 19:27:12 curt +Merged in make system changes from Bob Kuehne +This should simplify things tremendously. + +Revision 1.2 1997/12/15 23:54:54 curt +Add xgl wrappers for debugging. +Generate terrain normals on the fly. + +Revision 1.1 1997/07/31 23:13:14 curt +Initial revision. + +Revision 1.1 1997/05/29 00:09:56 curt +Initial Flight Gear revision. + + * Revision 1.5 1994/01/11 18:47:05 bjax + * Changed include files to use types and constants, not ls_eom.h + * Also changed DATA type to SCALAR type. + * + * Revision 1.4 1993/12/14 21:06:47 bjax + * Removed global variable references Altitude and Latitude. EBJ + * + * Revision 1.3 1993/06/02 15:03:40 bjax + * Made new subroutine for calculating geodetic to geocentric; changed name + * of forward conversion routine from ls_geodesy to ls_geoc_to_geod. + * + +---------------------------------------------------------------------------- + + REFERENCES: + + [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft + Control and Simulation", Wiley and Sons, 1992. + ISBN 0-471-61397-5 + + +---------------------------------------------------------------------------- + + CALLED BY: ls_aux + +---------------------------------------------------------------------------- + + CALLS TO: + +---------------------------------------------------------------------------- + + INPUTS: + lat_geoc Geocentric latitude, radians, + = North + radius C.G. radius to earth center, ft + +---------------------------------------------------------------------------- + + OUTPUTS: + lat_geod Geodetic latitude, radians, + = North + alt C.G. altitude above mean sea level, ft + sea_level_r radius from earth center to sea level at + local vertical (surface normal) of C.G. + +--------------------------------------------------------------------------*/ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:21:11 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.4 1998/01/27 00:47:59 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.3 1998/01/19 19:27:12 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.2 1997/12/15 23:54:54 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.1 1997/07/31 23:13:14 curt + * Initial revision. + * + */ diff --git a/SplitTris/fg_geodesy.h b/SplitTris/fg_geodesy.h new file mode 100644 index 000000000..a40b22df4 --- /dev/null +++ b/SplitTris/fg_geodesy.h @@ -0,0 +1,163 @@ +/************************************************************************** + * fg_geodesy.h -- routines to convert between geodetic and geocentric + * coordinate systems. + * + * Copied and adapted directly from LaRCsim/ls_geodesy.c + * + * See below for the complete original LaRCsim comments. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#ifndef _FG_GEODESY_H +#define _FG_GEODESY_H + + +/* fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) + * INPUTS: + * lat_geoc Geocentric latitude, radians, + = North + * radius C.G. radius to earth center, ft + * + * OUTPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * sea_level_r radius from earth center to sea level at + * local vertical (surface normal) of C.G. + */ + +void fgGeocToGeod( double lat_geoc, double radius, double + *lat_geod, double *alt, double *sea_level_r ); + +/* fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) + * INPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * + * OUTPUTS: + * sl_radius SEA LEVEL radius to earth center, ft (add Altitude to + * get true distance from earth center. + * lat_geoc Geocentric latitude, radians, + = North + * + */ + +void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, + double *lat_geoc ); + + + +/*************************************************************************** + + TITLE: ls_geodesy + +---------------------------------------------------------------------------- + + FUNCTION: Converts geocentric coordinates to geodetic positions + +---------------------------------------------------------------------------- + + MODULE STATUS: developmental + +---------------------------------------------------------------------------- + + GENEALOGY: Written as part of LaRCSim project by E. B. Jackson + +---------------------------------------------------------------------------- + + DESIGNED BY: E. B. Jackson + + CODED BY: E. B. Jackson + + MAINTAINED BY: E. B. Jackson + +---------------------------------------------------------------------------- + + MODIFICATION HISTORY: + + DATE PURPOSE BY + + 930208 Modified to avoid singularity near polar region. EBJ + 930602 Moved backwards calcs here from ls_step. EBJ + 931214 Changed erroneous Latitude and Altitude variables to + *lat_geod and *alt in routine ls_geoc_to_geod. EBJ + 940111 Changed header files from old ls_eom.h style to ls_types, + and ls_constants. Also replaced old DATA type with new + SCALAR type. EBJ + + CURRENT RCS HEADER: + +$Header$ +$Log$ +Revision 1.1 1998/04/08 23:21:12 curt +Adopted Gnu automake/autoconf system. + +Revision 1.2 1998/01/22 02:59:38 curt +Changed #ifdef FILE_H to #ifdef _FILE_H + +Revision 1.1 1997/07/31 23:13:14 curt +Initial revision. + +Revision 1.1 1997/05/29 00:09:56 curt +Initial Flight Gear revision. + + * Revision 1.5 1994/01/11 18:47:05 bjax + * Changed include files to use types and constants, not ls_eom.h + * Also changed DATA type to SCALAR type. + * + * Revision 1.4 1993/12/14 21:06:47 bjax + * Removed global variable references Altitude and Latitude. EBJ + * + * Revision 1.3 1993/06/02 15:03:40 bjax + * Made new subroutine for calculating geodetic to geocentric; changed name + * of forward conversion routine from ls_geodesy to ls_geoc_to_geod. + * + +---------------------------------------------------------------------------- + + REFERENCES: + + [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft + Control and Simulation", Wiley and Sons, 1992. + ISBN 0-471-61397-5 + + +---------------------------------------------------------------------------- + + CALLED BY: ls_aux + +---------------------------------------------------------------------------- + + CALLS TO: + +---------------------------------------------------------------------------- + + INPUTS: + lat_geoc Geocentric latitude, radians, + = North + radius C.G. radius to earth center, ft + +---------------------------------------------------------------------------- + + OUTPUTS: + lat_geod Geodetic latitude, radians, + = North + alt C.G. altitude above mean sea level, ft + sea_level_r radius from earth center to sea level at + local vertical (surface normal) of C.G. + +--------------------------------------------------------------------------*/ + + +#endif /* _FG_GEODESY_H */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:21:12 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.2 1998/01/22 02:59:38 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * + * Revision 1.1 1997/07/31 23:13:14 curt + * Initial revision. + * + */ diff --git a/SplitTris/mat3.h b/SplitTris/mat3.h new file mode 100644 index 000000000..58c4b9e07 --- /dev/null +++ b/SplitTris/mat3.h @@ -0,0 +1,147 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* ------------------------------------------------------------------------- + Public MAT3 include file + ------------------------------------------------------------------------- */ + +#ifndef MAT3_HAS_BEEN_INCLUDED +#define MAT3_HAS_BEEN_INCLUDED + +/* ----------------------------- Constants ------------------------------ */ + +/* + * Make sure the math library .h file is included, in case it wasn't. + */ + +#ifndef HUGE +#include +#endif +#include + + +#define MAT3_DET0 -1 /* Indicates singular mat */ +#define MAT3_EPSILON 1e-12 /* Close enough to zero */ +#define MAT3_PI 3.141592653589793 /* Pi */ + +/* ------------------------------ Types --------------------------------- */ + +typedef double MAT3mat[4][4]; /* 4x4 matrix */ +typedef double MAT3vec[3]; /* Vector */ +typedef double MAT3hvec[4]; /* Vector with homogeneous coord */ + +/* ------------------------------ Macros -------------------------------- */ + +/* Tests if a number is within EPSILON of zero */ +#define MAT3_IS_ZERO(N) ((N) < MAT3_EPSILON && (N) > -MAT3_EPSILON) + +/* Sets a vector to the three given values */ +#define MAT3_SET_VEC(V,X,Y,Z) ((V)[0]=(X), (V)[1]=(Y), (V)[2]=(Z)) + +/* Tests a vector for all components close to zero */ +#define MAT3_IS_ZERO_VEC(V) (MAT3_IS_ZERO((V)[0]) && \ + MAT3_IS_ZERO((V)[1]) && \ + MAT3_IS_ZERO((V)[2])) + +/* Dot product of two vectors */ +#define MAT3_DOT_PRODUCT(V1,V2) \ + ((V1)[0]*(V2)[0] + (V1)[1]*(V2)[1] + (V1)[2]*(V2)[2]) + +/* Copy one vector to other */ +#define MAT3_COPY_VEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2]) + +/* Normalize vector to unit length, using TEMP as temporary variable. + * TEMP will be zero if vector has zero length */ +#define MAT3_NORMALIZE_VEC(V,TEMP) \ + if ((TEMP = sqrt(MAT3_DOT_PRODUCT(V,V))) > MAT3_EPSILON) { \ + TEMP = 1.0 / TEMP; \ + MAT3_SCALE_VEC(V,V,TEMP); \ + } else TEMP = 0.0 + +/* Scale vector by given factor, storing result vector in RESULT_V */ +#define MAT3_SCALE_VEC(RESULT_V,V,SCALE) \ + MAT3_SET_VEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), (V)[2]*(SCALE)) + +/* Adds vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_ADD_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2]) + +/* Subtracts vector V2 from V1, storing result in RESULT_V */ +#define MAT3_SUB_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2]) + +/* Multiplies vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_MULT_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2]) + +/* Sets RESULT_V to the linear combination of V1 and V2, scaled by + * SCALE1 and SCALE2, respectively */ +#define MAT3_LINEAR_COMB(RESULT_V,SCALE1,V1,SCALE2,V2) \ + MAT3_SET_VEC(RESULT_V, (SCALE1)*(V1)[0] + (SCALE2)*(V2)[0], \ + (SCALE1)*(V1)[1] + (SCALE2)*(V2)[1], \ + (SCALE1)*(V1)[2] + (SCALE2)*(V2)[2]) + +/* Several of the vector macros are useful for homogeneous-coord vectors */ +#define MAT3_SET_HVEC(V,X,Y,Z,W) ((V)[0]=(X), (V)[1]=(Y), \ + (V)[2]=(Z), (V)[3]=(W)) + +#define MAT3_COPY_HVEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2], \ + (TO)[3] = (FROM)[3]) + +#define MAT3_SCALE_HVEC(RESULT_V,V,SCALE) \ + MAT3_SET_HVEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), \ + (V)[2]*(SCALE), (V)[3]*(SCALE)) + +#define MAT3_ADD_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2], (V1)[3]+(V2)[3]) + +#define MAT3_SUB_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2], (V1)[3]-(V2)[3]) + +#define MAT3_MULT_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2], (V1)[3]*(V2)[3]) + +/* ------------------------------ Entries ------------------------------- */ + + +/* In MAT3geom.c */ +void MAT3direction_matrix (MAT3mat result_mat, MAT3mat mat); +int MAT3normal_matrix (MAT3mat result_mat, MAT3mat mat); +void MAT3rotate (MAT3mat result_mat, MAT3vec axis, double angle_in_radians); +void MAT3translate (MAT3mat result_mat, MAT3vec trans); +void MAT3scale (MAT3mat result_mat, MAT3vec scale); +void MAT3shear(MAT3mat result_mat, double xshear, double yshear); + +/* In MAT3mat.c */ +void MAT3identity(MAT3mat); +void MAT3zero(MAT3mat); +void MAT3copy (MAT3mat to, MAT3mat from); +void MAT3mult (MAT3mat result, MAT3mat, MAT3mat); +void MAT3transpose (MAT3mat result, MAT3mat); +int MAT3invert (MAT3mat result, MAT3mat); +void MAT3print (MAT3mat, FILE *fp); +void MAT3print_formatted (MAT3mat, FILE *fp, + char *title, char *head, char *format, char *tail); +extern int MAT3equal( void ); +extern double MAT3trace( void ); +extern int MAT3power( void ); +extern int MAT3column_reduce( void ); +extern int MAT3kernel_basis( void ); + +/* In MAT3vec.c */ +void MAT3mult_vec(MAT3vec result_vec, MAT3vec vec, MAT3mat mat); +int MAT3mult_hvec (MAT3hvec result_vec, MAT3hvec vec, MAT3mat mat, int normalize); +void MAT3cross_product(MAT3vec result,MAT3vec,MAT3vec); +void MAT3perp_vec(MAT3vec result_vec, MAT3vec vec, int is_unit); + +#endif /* MAT3_HAS_BEEN_INCLUDED */ + diff --git a/SplitTris/polar.c b/SplitTris/polar.c new file mode 100644 index 000000000..c304f183b --- /dev/null +++ b/SplitTris/polar.c @@ -0,0 +1,124 @@ +/************************************************************************** + * polar.c -- routines to deal with polar math and transformations + * + * Written by Curtis Olson, started June 1997. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#include +#include + +#include +#include + + +/* we can save these values between calls for efficiency */ +static double st, ct, sp, cp; + + +/* Convert a polar coordinate to a cartesian coordinate. Lon and Lat + * must be specified in radians. The FG convention is for distances + * to be specified in meters */ +struct fgCartesianPoint fgPolarToCart(double lon, double lat, double radius) { + struct fgCartesianPoint pnew; + + pnew.x = cos(lon) * cos(lat) * radius; + pnew.y = sin(lon) * cos(lat) * radius; + pnew.z = sin(lat) * radius; + + return(pnew); +} + + +/* Precalculate as much as possible so we can do a batch of transforms + * through the same angles, will rotates a cartesian point about the + * center of the earth by Theta (longitude axis) and Phi (latitude + * axis) */ + +/* Here are the unoptimized transformation equations + + x' = cos(Phi) * cos(Theta) * x + cos(Phi) * sin(Theta) * y + + sin(Phi) * z + y' = -sin(Theta) * x + cos(Theta) * y + z' = -sin(Phi) * sin(Theta) * y - sin(Phi) * cos(Theta) * x + + cos(Phi) * z; + + */ +void fgRotateBatchInit(double Theta, double Phi) { + printf("Theta = %.3f, Phi = %.3f\n", Theta, Phi); + + st = sin(Theta); + ct = cos(Theta); + sp = sin(-Phi); + cp = cos(-Phi); +} + +/* Rotates a cartesian point about the center of the earth by Theta + * (longitude axis) and Phi (latitude axis) */ +struct fgCartesianPoint fgRotateCartesianPoint(struct fgCartesianPoint p) { + struct fgCartesianPoint p1, p2; + + /* printf("start = %.3f %.3f %.3f\n", p.x, p.y, p.z); */ + + /* rotate about the z axis */ + p1.x = ct * p.x - st * p.y; + p1.y = st * p.x + ct * p.y; + p1.z = p.z; + + /* printf("step 1 = %.3f %.3f %.3f\n", p1.x, p1.y, p1.z); */ + + /* rotate new point about y axis */ + p2.x = cp * p1.x + sp * p1.z; + p2.y = p1.y; + p2.z = cp * p1.z - sp * p1.x; + + /* printf("cp = %.5f, sp = %.5f\n", cp, sp); */ + /* printf("(1) = %.5f, (2) = %.5f\n", cp * p1.z, sp * p1.x); */ + + /* printf("step 2 = %.3f %.3f %.3f\n", p2.x, p2.y, p2.z); */ + + return(p2); +} + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:21:12 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.5 1998/01/27 00:48:00 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.4 1998/01/19 19:27:12 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.3 1997/12/15 23:54:54 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.2 1997/07/31 22:52:27 curt + * Working on redoing internal coordinate systems & scenery transformations. + * + * Revision 1.1 1997/07/07 21:02:36 curt + * Initial revision. + * */ diff --git a/SplitTris/polar.h b/SplitTris/polar.h new file mode 100644 index 000000000..2164d995a --- /dev/null +++ b/SplitTris/polar.h @@ -0,0 +1,93 @@ +/************************************************************************** + * polar.h -- routines to deal with polar math and transformations + * + * Written by Curtis Olson, started June 1997. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#ifndef _POLAR_H +#define _POLAR_H + + +#include + + +/* Convert a polar coordinate to a cartesian coordinate. Lon and Lat + * must be specified in radians. The FG convention is for distances + * to be specified in meters */ +struct fgCartesianPoint fgPolarToCart(double lon, double lat, double radius); + + +/* Precalculate as much as possible so we can do a batch of transforms + * through the same angles, will rotates a cartesian point about the + * center of the earth by Theta (longitude axis) and Phi (latitude + * axis) */ + +/* Here are the unoptimized transformation equations + + x' = cos(Phi) * cos(Theta) * x + cos(Phi) * sin(Theta) * y + + sin(Phi) * z + y' = -sin(Theta) * x + cos(Theta) * y + z' = -sin(Phi) * sin(Theta) * y - sin(Phi) * cos(Theta) * x + + cos(Phi) * z; + + */ +void fgRotateBatchInit(double Theta, double Phi); + + +/* Rotates a cartesian point about the center of the earth by Theta + * (longitude axis) and Phi (latitude axis) */ +struct fgCartesianPoint fgRotateCartesianPoint(struct fgCartesianPoint p); + + +#endif /* _POLAR_H */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:21:13 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.7 1998/01/27 00:48:00 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.6 1998/01/22 02:59:39 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * + * Revision 1.5 1998/01/19 19:27:13 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.4 1997/12/15 23:54:55 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.3 1997/07/31 22:52:28 curt + * Working on redoing internal coordinate systems & scenery transformations. + * + * Revision 1.2 1997/07/23 21:52:21 curt + * Put comments around the text after an #endif for increased portability. + * + * Revision 1.1 1997/07/07 21:02:37 curt + * Initial revision. + * + */ diff --git a/SplitTris/splittris.c b/SplitTris/splittris.c index 36b8db356..38b87b227 100644 --- a/SplitTris/splittris.c +++ b/SplitTris/splittris.c @@ -36,11 +36,11 @@ #include #include -#include -#include -#include -#include +#include +#include "fg_geodesy.h" +#include "mat3.h" +#include "polar.h" int nodecount, tricount; double xmin, xmax, ymin, ymax; @@ -612,9 +612,12 @@ int main(int argc, char **argv) { /* $Log$ -/* Revision 1.6 1998/03/03 15:36:13 curt -/* Tweaks for compiling with g++ +/* Revision 1.7 1998/04/08 23:21:13 curt +/* Adopted Gnu automake/autoconf system. /* + * Revision 1.6 1998/03/03 15:36:13 curt + * Tweaks for compiling with g++ + * * Revision 1.5 1998/03/03 03:37:04 curt * Cumulative tweaks. * diff --git a/Tools/Makefile b/Tools/Makefile deleted file mode 100644 index 8c1a7750b..000000000 --- a/Tools/Makefile +++ /dev/null @@ -1,141 +0,0 @@ -#--------------------------------------------------------------------------- -# Toplevel FGTools Makefile -# -# Written by Curtis Olson, started October 1997. -# -# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# $Id$ -# (Log is kept at end of this file) -#--------------------------------------------------------------------------- - - -include $(FG_ROOT_SRC)/commondefs - - -LIBDIRS = DEM gpc2.01 -SUBDIRS = Areas AssemTris Dem2node DemRaw2Ascii FixNode FixObj \ - SplitTris Stripe_u Tri2obj Triangle -ORDEREDDIRS = $(LIBDIRS) $(SUBDIRS) - - -all: - for dir in $(ORDEREDDIRS); do \ - ( cd $$dir; $(MAKE) ) ; \ - done - -depend: - for dir in $(ORDEREDDIRS); do \ - ( echo "Making depend in $$dir"; \ - cd $$dir; $(CC) $(CFLAGS) -M *.c > depend ) ; \ - done - -Makefile-os2: - cat Makefile | perl mkmfos2.pl > Makefile.os2; \ - for dir in $(ORDEREDDIRS); do \ - ( echo "Making Makefile.os2 in $$dir"; \ - cat $$dir/Makefile | perl mkmfos2.pl > $$dir/Makefile.os2; \ - cat $$dir/depend | perl mkmfos2.pl > $$dir/depend.os2) ; \ - done - -clean: - -rm -f *.os2 *~ - for dir in $(ORDEREDDIRS); do \ - (cd $$dir; $(MAKE) clean) ; \ - done - - -source-tar: clean - (cd ..; \ - tar cvzf demtools-$(FG_VERSION).tar.gz Tools/Makefile Tools/README \ - Tools/Todo Tools/make.inc Tools/process-dem.pl Tools/AssemTris \ - Tools/DEM Tools/gpc2.01 Tools/Dem2node Tools/DemRaw2Ascii \ - Tools/FixNode Tools/FixObj Tools/SplitTris Tools/Stripe_u \ - Tools/Tri2obj Tools/Triangle) - -source-zip: clean - (cd ..; \ - zip -r demtools-$(FG_VERSION).zip Tools/Makefile Tools/README \ - Tools/Todo Tools/make.inc Tools/process-dem.pl Tools/AssemTris \ - Tools/DEM Tools/gpc2.01 Tools/Dem2node Tools/DemRaw2Ascii \ - Tools/FixNode Tools/FixObj Tools/SplitTris Tools/Stripe_u \ - Tools/Tri2obj Tools/Triangle) - -bin-tar: all - echo "need to fix this" -# cp GLUT/fg0 GLUT/runfg .. -# (cd ../..; \ -# tar cvzf bin-$(FG_VERSION).tar.gz FlightGear/fgtop FlightGear/fg0 \ -# FlightGear/runfg FlightGear/COPYING FlightGear/Docs FlightGear/Thanks) - -bin-zip: - echo "need to fix this" -# cp GLUT/fg0.exe GLUT/runfg.bat GLUT/cygwin.dll .. -# (cd ../..; \ -# zip -r bin-$(FG_VERSION).zip FlightGear/fgtop FlightGear/fg0.exe \ -# FlightGear/runfg.bat FlightGear/cygwin.dll FlightGear/COPYING \ -# FlightGear/Docs FlightGear/Thanks) - - -#--------------------------------------------------------------------------- -# $Log$ -# Revision 1.14 1998/04/06 21:09:37 curt -# Additional win32 support. -# Fixed a bad bug in dem file parsing that was causing the output to be -# flipped about x = y. -# -# Revision 1.13 1998/03/19 02:52:51 curt -# Updated to reflect some minor tool reorganization and the creation of class -# to handle DEM processing needs. -# -# Revision 1.12 1998/03/19 01:48:34 curt -# Added gpc-2.01 (generic polygon clipping library) -# -# Revision 1.11 1998/03/03 21:54:43 curt -# Changes to process 30 arcsec binary DEM files. -# -# Revision 1.10 1998/03/03 15:36:11 curt -# Tweaks for compiling with g++ -# -# Revision 1.9 1998/03/03 01:21:17 curt -# Added DemRaw2Ascii -# -# Revision 1.8 1998/01/31 00:41:19 curt -# Made a few changes converting floats to doubles. -# -# Revision 1.7 1998/01/27 18:36:53 curt -# Lots of updates to get back in sync with changes made over in .../Src/ -# -# Revision 1.6 1998/01/21 02:55:42 curt -# Incorporated new make system from Bob Kuehne . -# -# Revision 1.5 1998/01/14 15:55:34 curt -# Finished splittris, started assemtris. -# -# Revision 1.4 1997/12/10 01:18:25 curt -# Initial revision. -# -# Revision 1.3 1997/11/27 00:18:26 curt -# Added FixNode -# -# Revision 1.2 1997/11/14 00:31:06 curt -# Abandon Tri2terrain ... replace with Tri2obj so we can use an existing -# tri-stripper. -# -# Revision 1.1 1997/10/20 19:52:18 curt -# Initial revision. -# diff --git a/Tools/Makefile.am b/Tools/Makefile.am new file mode 100644 index 000000000..e8ab79034 --- /dev/null +++ b/Tools/Makefile.am @@ -0,0 +1,14 @@ +EXTRA_DIST = process-dem.pl + +SUBDIRS = \ + AssemTris \ + DEM \ + Dem2node \ + FixNode \ + FixObj \ + SplitTris \ + Stripe_u \ + Tri2obj \ + Triangle + +bin_SCRIPTS = process-dem.pl diff --git a/Tools/Makefile.in b/Tools/Makefile.in new file mode 100644 index 000000000..03dc3845e --- /dev/null +++ b/Tools/Makefile.in @@ -0,0 +1,297 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +EXTRA_DIST = process-dem.pl + +SUBDIRS = \ + AssemTris \ + DEM \ + Dem2node \ + FixNode \ + FixObj \ + SplitTris \ + Stripe_u \ + Tri2obj \ + Triangle + +bin_SCRIPTS = process-dem.pl +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +SCRIPTS = $(bin_SCRIPTS) + +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +all: all-recursive all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Tools/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + target=`echo $@ | sed s/-recursive//`; \ + echo "Making $$target in $$subdir"; \ + (cd $$subdir && $(MAKE) $$target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + done; \ + for subdir in $$rev; do \ + target=`echo $@ | sed s/-recursive//`; \ + echo "Making $$target in $$subdir"; \ + (cd $$subdir && $(MAKE) $$target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + (cd $$subdir && $(MAKE) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Tools + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Tools/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + for subdir in $(SUBDIRS); do \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + done +info: info-recursive +dvi: dvi-recursive +check: all-am + $(MAKE) check-recursive +installcheck: installcheck-recursive +all-am: Makefile $(SCRIPTS) + +install-exec-am: install-binSCRIPTS + +uninstall-am: uninstall-binSCRIPTS + +install-exec: install-exec-recursive install-exec-am + @$(NORMAL_INSTALL) + +install-data: install-data-recursive + @$(NORMAL_INSTALL) + +install: install-recursive install-exec-am + @: + +uninstall: uninstall-recursive uninstall-am + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: installdirs-recursive + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +clean-am: clean-tags clean-generic mostlyclean-am + +distclean-am: distclean-tags distclean-generic clean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + +mostlyclean: mostlyclean-recursive mostlyclean-am + +clean: clean-recursive clean-am + +distclean: distclean-recursive distclean-am + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-recursive maintainer-clean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: uninstall-binSCRIPTS install-binSCRIPTS install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info dvi \ +installcheck all-am install-exec-am uninstall-am install-exec \ +install-data install uninstall all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Tools/make.inc b/Tools/make.inc deleted file mode 100644 index da1c732bc..000000000 --- a/Tools/make.inc +++ /dev/null @@ -1,128 +0,0 @@ -# Hey Emacs, this is a Makefile. -*- Mode: Makefile -*- -# -# Common FGTools Makefile section -# -# Written by Curtis Olson, started October 1997. -# -# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# $Id$ -# (Log is kept at end of this file) -#--------------------------------------------------------------------------- - - -VERSION = 0.02 - -#--------------------------------------------------------------------------- -# Choose your weapons -#--------------------------------------------------------------------------- - -CC = gcc -FLEX = flex -f -L -BISON = bison -v --no-lines -AR = ar -RANLIB = ranlib - - -#--------------------------------------------------------------------------- -# Global Compile Options -# -# You may set FG_CFLAGS to include any of the following options depending on -# your environment: -# -# -g - Compile with debugging symbols -# -# -Wall - Enable full compiler warnings -# -# -O2 - Enable compiler optimization -# -#--------------------------------------------------------------------------- - -GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(VERSION)\" - - -#--------------------------------------------------------------------------- -# Platform specific compile options, these should be set with FG_CFLAGS -# below. These have been predefined for the supported platforms below. -# -# -DNO_PRINTF - Disable all printf()'s. Works by replacing the printf -# fuction with an empty function. -# -# -DUSE_ITIMER - Use setitimer(), getitimer(), and signal() to mimic -# a real time system and call the flight model routines -# at a regular interval, rather than between screen updates -# which can be highly variable. This can make the flight -# model calculations much smoother. -# -# -DUSE_FTIME - Use ftime() to get an accurate current time instead of -# gettimeofday() -# -# -DUSE_RAND - Use rand() instead of random() -# -#--------------------------------------------------------------------------- - - -#--------------------------------------------------------------------------- -# Uncomment one of the following sections depending on your system -# -# You may set FG_GRAPHICS to include any of the following options depending -# on your environment: -#--------------------------------------------------------------------------- - -#--------------------------------------------------------------------------- -# SGI IRIX with the GLUT toolkit -# (Surprisingly, this also works on our SunOS 4.x machine with the -# way we have Mesa & Glut installed.) -# -# INTERFACE_FLAGS = -DGLUT -# INTERFACE_LIBS = -lglut -# INTERFACE_FILES = GLUTmain.c GLUTkey.c -# GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11 -# FG_CFLAGS = $(GLOBAL_CFLAGS) -#--------------------------------------------------------------------------- - -#--------------------------------------------------------------------------- -# Linux/Mesa with the GLUT toolkit -# -INTERFACE_FLAGS = -DGLUT -INTERFACE_LIBS = -lglut -INTERFACE_FILES = GLUTmain.c GLUTkey.c -MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL -X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 -GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS) -FG_CFLAGS = $(GLOBAL_CFLAGS) -#--------------------------------------------------------------------------- - -#--------------------------------------------------------------------------- -# Cygnus Win32 (gcc based) with a static version of the GLUT toolkit -# -# INTERFACE_FLAGS = -DGLUT -# INTERFACE_LIBS = ../Win32/libglut.a -# INTERFACE_FILES = GLUTmain.c GLUTkey.c -# GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32 -# FG_CFLAGS = $(GLOBAL_CFLAGS) -DWIN32 -DUSE_RAND -#--------------------------------------------------------------------------- - - -#--------------------------------------------------------------------------- -# $Log$ -# Revision 1.2 1997/12/10 01:18:26 curt -# Initial revision. -# -# Revision 1.1 1997/10/20 19:52:18 curt -# Initial revision. -# diff --git a/Tools/process-dem.pl b/Tools/process-dem.pl index d82b9b5ce..a9454b0b8 100755 --- a/Tools/process-dem.pl +++ b/Tools/process-dem.pl @@ -28,7 +28,7 @@ $| = 1; # flush buffers after every write -$do_demfit = 1; +$do_dem2node = 1; $do_triangle_1 = 1; $do_fixnode = 1; $do_splittris = 1; @@ -69,8 +69,8 @@ while ( $dem_file = shift(@ARGV) ) { } - if ( $do_demfit ) { - demfit() ; + if ( $do_dem2node ) { + dem2node() ; } else { $subdir = "../Scenery/w100n040/w093n045"; print "WARNING: Hardcoding subdir = $subdir\n"; @@ -123,7 +123,7 @@ sub file_root { # splits dem file into 64 file.node's which contain the # irregularly fitted vertices -sub demfit { +sub dem2node { if ( $dem_file =~ m/.gz$/ ) { $command = "gzip -dc $dem_file | Dem2node/dem2node $ENV{FG_ROOT} - $error"; } else { @@ -387,6 +387,9 @@ sub fixobj { #--------------------------------------------------------------------------- # $Log$ +# Revision 1.15 1998/04/08 23:24:07 curt +# Adopted Gnu automake/autoconf system. +# # Revision 1.14 1998/04/06 21:09:38 curt # Additional win32 support. # Fixed a bad bug in dem file parsing that was causing the output to be diff --git a/Tri2obj/MAT3vec.c b/Tri2obj/MAT3vec.c new file mode 100644 index 000000000..24f2939af --- /dev/null +++ b/Tri2obj/MAT3vec.c @@ -0,0 +1,149 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* -------------------------------------------------------------------------- + * This file contains routines that operate on matrices and vectors, or + * vectors and vectors. + * -------------------------------------------------------------------------*/ + +/* #include "sphigslocal.h" */ + +/* -------------------------- Static Routines ---------------------------- */ + +/* ------------------------- Internal Routines --------------------------- */ + +/* -------------------------- Public Routines ---------------------------- */ + +/* + * Multiplies a vector by a matrix, setting the result vector. + * It assumes all homogeneous coordinates are 1. + * The two vectors involved may be the same. + */ + +#include + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + + +void +MAT3mult_vec(double *result_vec, register double *vec, register double (*mat)[4]) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + mat[3][2]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Multiplies a vector of size 4 by a matrix, setting the result vector. + * The fourth element of the vector is the homogeneous coordinate, which + * may or may not be 1. If the "normalize" parameter is TRUE, then the + * result vector will be normalized so that the homogeneous coordinate is 1. + * The two vectors involved may be the same. + * This returns zero if the vector was to be normalized, but couldn't be. + */ + +int +MAT3mult_hvec(double *result_vec, register double *vec, register double (*mat)[4], int normalize) +{ + MAT3hvec tempvec; + double norm_fac; + register double *temp = tempvec; + register int ret = TRUE; + + temp[0] = vec[0] * mat[0][0] + vec[1] * mat[1][0] + + vec[2] * mat[2][0] + vec[3] * mat[3][0]; + temp[1] = vec[0] * mat[0][1] + vec[1] * mat[1][1] + + vec[2] * mat[2][1] + vec[3] * mat[3][1]; + temp[2] = vec[0] * mat[0][2] + vec[1] * mat[1][2] + + vec[2] * mat[2][2] + vec[3] * mat[3][2]; + temp[3] = vec[0] * mat[0][3] + vec[1] * mat[1][3] + + vec[2] * mat[2][3] + vec[3] * mat[3][3]; + + /* Normalize if asked for, possible, and necessary */ + if (normalize) { + if (MAT3_IS_ZERO(temp[3])) { +#ifndef THINK_C + fprintf (stderr, + "Can't normalize vector: homogeneous coordinate is 0"); +#endif + ret = FALSE; + } + else { + norm_fac = 1.0 / temp[3]; + MAT3_SCALE_VEC(result_vec, temp, norm_fac); + result_vec[3] = 1.0; + } + } + else MAT3_COPY_HVEC(result_vec, temp); + + return(ret); +} + +/* + * Sets the first vector to be the cross-product of the last two vectors. + */ + +void +MAT3cross_product(double *result_vec, register double *vec1, register double *vec2) +{ + MAT3vec tempvec; + register double *temp = tempvec; + + temp[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; + temp[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; + temp[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; + + MAT3_COPY_VEC(result_vec, temp); +} + +/* + * Finds a vector perpendicular to vec and stores it in result_vec. + * Method: take any vector (we use <0,1,0>) and subtract the + * portion of it pointing in the vec direction. This doesn't + * work if vec IS <0,1,0> or is very near it. So if this is + * the case, use <0,0,1> instead. + * If "is_unit" is TRUE, the given vector is assumed to be unit length. + */ + +#define SELECT .7071 /* selection constant (roughly .5*sqrt(2) */ + +void +MAT3perp_vec(double *result_vec, double *vec, int is_unit) +{ + MAT3vec norm; + double dot; + + MAT3_SET_VEC(result_vec, 0.0, 1.0, 0.0); + + MAT3_COPY_VEC(norm, vec); + + if (! is_unit) MAT3_NORMALIZE_VEC(norm, dot); + + /* See if vector is too close to <0,1,0>. If so, use <0,0,1> */ + if ((dot = MAT3_DOT_PRODUCT(norm, result_vec)) > SELECT || dot < -SELECT) { + result_vec[1] = 0.0; + result_vec[2] = 1.0; + dot = MAT3_DOT_PRODUCT(norm, result_vec); + } + + /* Subtract off non-perpendicular part */ + result_vec[0] -= dot * norm[0]; + result_vec[1] -= dot * norm[1]; + result_vec[2] -= dot * norm[2]; + + /* Make result unit length */ + MAT3_NORMALIZE_VEC(result_vec, dot); +} diff --git a/Tri2obj/Makefile b/Tri2obj/Makefile deleted file mode 100644 index abc733a89..000000000 --- a/Tri2obj/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -#--------------------------------------------------------------------------- -# Makefile -# -# Written by Curtis Olson, started October 1997. -# -# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# $Id$ -# (Log is kept at end of this file) -#--------------------------------------------------------------------------- - - -TARGET = tri2obj - -CFILES = tri2obj.c -LDLIBS = -lMath -lScenery -lm - - -include $(FG_ROOT_SRC)/commondefs - - -#--------------------------------------------------------------------------- -# Primary Targets -#--------------------------------------------------------------------------- - -$(TARGET): $(OBJECTS) - $(CC) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(LDLIBS) - - -include $(COMMONRULES) - - -#--------------------------------------------------------------------------- -# $Log$ -# Revision 1.5 1998/01/21 02:55:56 curt -# Incorporated new make system from Bob Kuehne . -# -# Revision 1.4 1998/01/17 01:25:39 curt -# Added support for shared normals. -# -# Revision 1.3 1997/12/02 13:13:32 curt -# Fixed problem with averaged vertex normals. -# -# Revision 1.2 1997/11/14 00:29:13 curt -# Transform scenery coordinates at this point in pipeline when scenery is -# being translated to .obj format, not when it is being loaded into the end -# renderer. Precalculate normals for each node as average of the normals -# of each containing polygon so Garoude shading is now supportable. -# -# Revision 1.1 1997/10/29 23:05:14 curt -# Initial revision. -# -# Revision 1.1 1997/10/23 23:12:09 curt -# Initial revision. -# diff --git a/Tri2obj/Makefile.am b/Tri2obj/Makefile.am new file mode 100644 index 000000000..4b3cba1f1 --- /dev/null +++ b/Tri2obj/Makefile.am @@ -0,0 +1,53 @@ +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started January 1998. +# +# Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +bin_PROGRAMS = tri2obj + +tri2obj_SOURCES = \ + tri2obj.c tri2obj.h \ + MAT3vec.c \ + fg_geodesy.c fg_geodesy.h \ + mat3.h \ + polar.c polar.h + +tri2obj_LDADD = \ + $(top_builddir)/Simulator/Scenery/Bucket/libBucket.la + +INCLUDES += -I../../Simulator + + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:22:13 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.2 1998/01/21 02:55:46 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.1 1998/01/15 02:45:25 curt +# Initial revision. +# + diff --git a/Tri2obj/Makefile.in b/Tri2obj/Makefile.in new file mode 100644 index 000000000..7bac2edd1 --- /dev/null +++ b/Tri2obj/Makefile.in @@ -0,0 +1,366 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started January 1998. +# +# Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id$ +# (Log is kept at end of this file) +#--------------------------------------------------------------------------- + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +bin_PROGRAMS = tri2obj + +tri2obj_SOURCES = \ + tri2obj.c tri2obj.h \ + MAT3vec.c \ + fg_geodesy.c fg_geodesy.h \ + mat3.h \ + polar.c polar.h + +tri2obj_LDADD = \ + $(top_builddir)/Simulator/Scenery/Bucket/libBucket.la +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../Simulator/Include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +tri2obj_OBJECTS = tri2obj.o MAT3vec.o fg_geodesy.o polar.o +tri2obj_DEPENDENCIES = \ +$(top_builddir)/Simulator/Scenery/Bucket/libBucket.la +tri2obj_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/MAT3vec.P .deps/fg_geodesy.P .deps/polar.P \ +.deps/tri2obj.P +SOURCES = $(tri2obj_SOURCES) +OBJECTS = $(tri2obj_OBJECTS) + +all: Makefile $(PROGRAMS) + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Tools/Tri2obj/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +tri2obj: $(tri2obj_OBJECTS) $(tri2obj_DEPENDENCIES) + @rm -f tri2obj + $(LINK) $(tri2obj_LDFLAGS) $(tri2obj_OBJECTS) $(tri2obj_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Tools/Tri2obj + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Tools/Tri2obj/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binPROGRAMS + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +clean: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean + +distclean: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-libtool maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info dvi installcheck install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +INCLUDES += -I../../Simulator + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/04/08 23:22:14 curt +# Adopted Gnu automake/autoconf system. +# +# Revision 1.2 1998/01/21 02:55:46 curt +# Incorporated new make system from Bob Kuehne . +# +# Revision 1.1 1998/01/15 02:45:25 curt +# Initial revision. +# + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Tri2obj/fg_geodesy.c b/Tri2obj/fg_geodesy.c new file mode 100644 index 000000000..bedd202b4 --- /dev/null +++ b/Tri2obj/fg_geodesy.c @@ -0,0 +1,230 @@ +/************************************************************************** + * fg_geodesy.c -- routines to convert between geodetic and geocentric + * coordinate systems. + * + * Copied and adapted directly from LaRCsim/ls_geodesy.c + * + * See below for the complete original LaRCsim comments. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#include + +#include + +#include "fg_geodesy.h" + + +/* ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator */ +#define ONE_SECOND 4.848136811E-6 + + +/* fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) + * INPUTS: + * lat_geoc Geocentric latitude, radians, + = North + * radius C.G. radius to earth center, ft + * + * OUTPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * sea_level_r radius from earth center to sea level at + * local vertical (surface normal) of C.G. + */ + +void fgGeocToGeod( double lat_geoc, double radius, double + *lat_geod, double *alt, double *sea_level_r ) +{ + double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha; + double sin_mu_a, denom,delt_lambda, lambda_sl, sin_lambda_sl; + + if( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) /* near North pole */ + || ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) /* near South pole */ + { + *lat_geod = lat_geoc; + *sea_level_r = EQUATORIAL_RADIUS_KM*E; + *alt = radius - *sea_level_r; + } else { + t_lat = tan(lat_geoc); + x_alpha = E*EQUATORIAL_RADIUS_KM/sqrt(t_lat*t_lat + E*E); + mu_alpha = atan2(sqrt(RESQ_KM - x_alpha*x_alpha),E*x_alpha); + if (lat_geoc < 0) mu_alpha = - mu_alpha; + sin_mu_a = sin(mu_alpha); + delt_lambda = mu_alpha - lat_geoc; + r_alpha = x_alpha/cos(lat_geoc); + l_point = radius - r_alpha; + *alt = l_point*cos(delt_lambda); + denom = sqrt(1-EPS*EPS*sin_mu_a*sin_mu_a); + rho_alpha = EQUATORIAL_RADIUS_KM*(1-EPS)/ + (denom*denom*denom); + delt_mu = atan2(l_point*sin(delt_lambda),rho_alpha + *alt); + *lat_geod = mu_alpha - delt_mu; + lambda_sl = atan( E*E * tan(*lat_geod) ); /* SL geoc. latitude */ + sin_lambda_sl = sin( lambda_sl ); + *sea_level_r = + sqrt(RESQ_KM / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl)); + } +} + + +/* fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) + * INPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * + * OUTPUTS: + * sl_radius SEA LEVEL radius to earth center, ft (add Altitude to + * get true distance from earth center. + * lat_geoc Geocentric latitude, radians, + = North + * + */ + +void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, + double *lat_geoc ) +{ + double lambda_sl, sin_lambda_sl, cos_lambda_sl, sin_mu, cos_mu, px, py; + + lambda_sl = atan( E*E * tan(lat_geod) ); /* sea level geocentric latitude */ + sin_lambda_sl = sin( lambda_sl ); + cos_lambda_sl = cos( lambda_sl ); + sin_mu = sin(lat_geod); /* Geodetic (map makers') latitude */ + cos_mu = cos(lat_geod); + *sl_radius = + sqrt(RESQ_KM / (1 + ((1/(E*E))-1)*sin_lambda_sl*sin_lambda_sl)); + py = *sl_radius*sin_lambda_sl + alt*sin_mu; + px = *sl_radius*cos_lambda_sl + alt*cos_mu; + *lat_geoc = atan2( py, px ); +} + + +/*************************************************************************** + + TITLE: ls_geodesy + +---------------------------------------------------------------------------- + + FUNCTION: Converts geocentric coordinates to geodetic positions + +---------------------------------------------------------------------------- + + MODULE STATUS: developmental + +---------------------------------------------------------------------------- + + GENEALOGY: Written as part of LaRCSim project by E. B. Jackson + +---------------------------------------------------------------------------- + + DESIGNED BY: E. B. Jackson + + CODED BY: E. B. Jackson + + MAINTAINED BY: E. B. Jackson + +---------------------------------------------------------------------------- + + MODIFICATION HISTORY: + + DATE PURPOSE BY + + 930208 Modified to avoid singularity near polar region. EBJ + 930602 Moved backwards calcs here from ls_step. EBJ + 931214 Changed erroneous Latitude and Altitude variables to + *lat_geod and *alt in routine ls_geoc_to_geod. EBJ + 940111 Changed header files from old ls_eom.h style to ls_types, + and ls_constants. Also replaced old DATA type with new + SCALAR type. EBJ + + CURRENT RCS HEADER: + +$Header$ +$Log$ +Revision 1.1 1998/04/08 23:22:14 curt +Adopted Gnu automake/autoconf system. + +Revision 1.4 1998/01/27 00:47:59 curt +Incorporated Paul Bleisch's new debug message +system and commandline/config file processing code. + +Revision 1.3 1998/01/19 19:27:12 curt +Merged in make system changes from Bob Kuehne +This should simplify things tremendously. + +Revision 1.2 1997/12/15 23:54:54 curt +Add xgl wrappers for debugging. +Generate terrain normals on the fly. + +Revision 1.1 1997/07/31 23:13:14 curt +Initial revision. + +Revision 1.1 1997/05/29 00:09:56 curt +Initial Flight Gear revision. + + * Revision 1.5 1994/01/11 18:47:05 bjax + * Changed include files to use types and constants, not ls_eom.h + * Also changed DATA type to SCALAR type. + * + * Revision 1.4 1993/12/14 21:06:47 bjax + * Removed global variable references Altitude and Latitude. EBJ + * + * Revision 1.3 1993/06/02 15:03:40 bjax + * Made new subroutine for calculating geodetic to geocentric; changed name + * of forward conversion routine from ls_geodesy to ls_geoc_to_geod. + * + +---------------------------------------------------------------------------- + + REFERENCES: + + [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft + Control and Simulation", Wiley and Sons, 1992. + ISBN 0-471-61397-5 + + +---------------------------------------------------------------------------- + + CALLED BY: ls_aux + +---------------------------------------------------------------------------- + + CALLS TO: + +---------------------------------------------------------------------------- + + INPUTS: + lat_geoc Geocentric latitude, radians, + = North + radius C.G. radius to earth center, ft + +---------------------------------------------------------------------------- + + OUTPUTS: + lat_geod Geodetic latitude, radians, + = North + alt C.G. altitude above mean sea level, ft + sea_level_r radius from earth center to sea level at + local vertical (surface normal) of C.G. + +--------------------------------------------------------------------------*/ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:22:14 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.4 1998/01/27 00:47:59 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.3 1998/01/19 19:27:12 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.2 1997/12/15 23:54:54 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.1 1997/07/31 23:13:14 curt + * Initial revision. + * + */ diff --git a/Tri2obj/fg_geodesy.h b/Tri2obj/fg_geodesy.h new file mode 100644 index 000000000..22a030ffb --- /dev/null +++ b/Tri2obj/fg_geodesy.h @@ -0,0 +1,163 @@ +/************************************************************************** + * fg_geodesy.h -- routines to convert between geodetic and geocentric + * coordinate systems. + * + * Copied and adapted directly from LaRCsim/ls_geodesy.c + * + * See below for the complete original LaRCsim comments. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#ifndef _FG_GEODESY_H +#define _FG_GEODESY_H + + +/* fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) + * INPUTS: + * lat_geoc Geocentric latitude, radians, + = North + * radius C.G. radius to earth center, ft + * + * OUTPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * sea_level_r radius from earth center to sea level at + * local vertical (surface normal) of C.G. + */ + +void fgGeocToGeod( double lat_geoc, double radius, double + *lat_geod, double *alt, double *sea_level_r ); + +/* fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) + * INPUTS: + * lat_geod Geodetic latitude, radians, + = North + * alt C.G. altitude above mean sea level, ft + * + * OUTPUTS: + * sl_radius SEA LEVEL radius to earth center, ft (add Altitude to + * get true distance from earth center. + * lat_geoc Geocentric latitude, radians, + = North + * + */ + +void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, + double *lat_geoc ); + + + +/*************************************************************************** + + TITLE: ls_geodesy + +---------------------------------------------------------------------------- + + FUNCTION: Converts geocentric coordinates to geodetic positions + +---------------------------------------------------------------------------- + + MODULE STATUS: developmental + +---------------------------------------------------------------------------- + + GENEALOGY: Written as part of LaRCSim project by E. B. Jackson + +---------------------------------------------------------------------------- + + DESIGNED BY: E. B. Jackson + + CODED BY: E. B. Jackson + + MAINTAINED BY: E. B. Jackson + +---------------------------------------------------------------------------- + + MODIFICATION HISTORY: + + DATE PURPOSE BY + + 930208 Modified to avoid singularity near polar region. EBJ + 930602 Moved backwards calcs here from ls_step. EBJ + 931214 Changed erroneous Latitude and Altitude variables to + *lat_geod and *alt in routine ls_geoc_to_geod. EBJ + 940111 Changed header files from old ls_eom.h style to ls_types, + and ls_constants. Also replaced old DATA type with new + SCALAR type. EBJ + + CURRENT RCS HEADER: + +$Header$ +$Log$ +Revision 1.1 1998/04/08 23:22:15 curt +Adopted Gnu automake/autoconf system. + +Revision 1.2 1998/01/22 02:59:38 curt +Changed #ifdef FILE_H to #ifdef _FILE_H + +Revision 1.1 1997/07/31 23:13:14 curt +Initial revision. + +Revision 1.1 1997/05/29 00:09:56 curt +Initial Flight Gear revision. + + * Revision 1.5 1994/01/11 18:47:05 bjax + * Changed include files to use types and constants, not ls_eom.h + * Also changed DATA type to SCALAR type. + * + * Revision 1.4 1993/12/14 21:06:47 bjax + * Removed global variable references Altitude and Latitude. EBJ + * + * Revision 1.3 1993/06/02 15:03:40 bjax + * Made new subroutine for calculating geodetic to geocentric; changed name + * of forward conversion routine from ls_geodesy to ls_geoc_to_geod. + * + +---------------------------------------------------------------------------- + + REFERENCES: + + [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft + Control and Simulation", Wiley and Sons, 1992. + ISBN 0-471-61397-5 + + +---------------------------------------------------------------------------- + + CALLED BY: ls_aux + +---------------------------------------------------------------------------- + + CALLS TO: + +---------------------------------------------------------------------------- + + INPUTS: + lat_geoc Geocentric latitude, radians, + = North + radius C.G. radius to earth center, ft + +---------------------------------------------------------------------------- + + OUTPUTS: + lat_geod Geodetic latitude, radians, + = North + alt C.G. altitude above mean sea level, ft + sea_level_r radius from earth center to sea level at + local vertical (surface normal) of C.G. + +--------------------------------------------------------------------------*/ + + +#endif /* _FG_GEODESY_H */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:22:15 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.2 1998/01/22 02:59:38 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * + * Revision 1.1 1997/07/31 23:13:14 curt + * Initial revision. + * + */ diff --git a/Tri2obj/mat3.h b/Tri2obj/mat3.h new file mode 100644 index 000000000..58c4b9e07 --- /dev/null +++ b/Tri2obj/mat3.h @@ -0,0 +1,147 @@ +/* Copyright 1988, Brown Computer Graphics Group. All Rights Reserved. */ + +/* ------------------------------------------------------------------------- + Public MAT3 include file + ------------------------------------------------------------------------- */ + +#ifndef MAT3_HAS_BEEN_INCLUDED +#define MAT3_HAS_BEEN_INCLUDED + +/* ----------------------------- Constants ------------------------------ */ + +/* + * Make sure the math library .h file is included, in case it wasn't. + */ + +#ifndef HUGE +#include +#endif +#include + + +#define MAT3_DET0 -1 /* Indicates singular mat */ +#define MAT3_EPSILON 1e-12 /* Close enough to zero */ +#define MAT3_PI 3.141592653589793 /* Pi */ + +/* ------------------------------ Types --------------------------------- */ + +typedef double MAT3mat[4][4]; /* 4x4 matrix */ +typedef double MAT3vec[3]; /* Vector */ +typedef double MAT3hvec[4]; /* Vector with homogeneous coord */ + +/* ------------------------------ Macros -------------------------------- */ + +/* Tests if a number is within EPSILON of zero */ +#define MAT3_IS_ZERO(N) ((N) < MAT3_EPSILON && (N) > -MAT3_EPSILON) + +/* Sets a vector to the three given values */ +#define MAT3_SET_VEC(V,X,Y,Z) ((V)[0]=(X), (V)[1]=(Y), (V)[2]=(Z)) + +/* Tests a vector for all components close to zero */ +#define MAT3_IS_ZERO_VEC(V) (MAT3_IS_ZERO((V)[0]) && \ + MAT3_IS_ZERO((V)[1]) && \ + MAT3_IS_ZERO((V)[2])) + +/* Dot product of two vectors */ +#define MAT3_DOT_PRODUCT(V1,V2) \ + ((V1)[0]*(V2)[0] + (V1)[1]*(V2)[1] + (V1)[2]*(V2)[2]) + +/* Copy one vector to other */ +#define MAT3_COPY_VEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2]) + +/* Normalize vector to unit length, using TEMP as temporary variable. + * TEMP will be zero if vector has zero length */ +#define MAT3_NORMALIZE_VEC(V,TEMP) \ + if ((TEMP = sqrt(MAT3_DOT_PRODUCT(V,V))) > MAT3_EPSILON) { \ + TEMP = 1.0 / TEMP; \ + MAT3_SCALE_VEC(V,V,TEMP); \ + } else TEMP = 0.0 + +/* Scale vector by given factor, storing result vector in RESULT_V */ +#define MAT3_SCALE_VEC(RESULT_V,V,SCALE) \ + MAT3_SET_VEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), (V)[2]*(SCALE)) + +/* Adds vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_ADD_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2]) + +/* Subtracts vector V2 from V1, storing result in RESULT_V */ +#define MAT3_SUB_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2]) + +/* Multiplies vectors V1 and V2, storing result in RESULT_V */ +#define MAT3_MULT_VEC(RESULT_V,V1,V2) \ + MAT3_SET_VEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2]) + +/* Sets RESULT_V to the linear combination of V1 and V2, scaled by + * SCALE1 and SCALE2, respectively */ +#define MAT3_LINEAR_COMB(RESULT_V,SCALE1,V1,SCALE2,V2) \ + MAT3_SET_VEC(RESULT_V, (SCALE1)*(V1)[0] + (SCALE2)*(V2)[0], \ + (SCALE1)*(V1)[1] + (SCALE2)*(V2)[1], \ + (SCALE1)*(V1)[2] + (SCALE2)*(V2)[2]) + +/* Several of the vector macros are useful for homogeneous-coord vectors */ +#define MAT3_SET_HVEC(V,X,Y,Z,W) ((V)[0]=(X), (V)[1]=(Y), \ + (V)[2]=(Z), (V)[3]=(W)) + +#define MAT3_COPY_HVEC(TO,FROM) ((TO)[0] = (FROM)[0], \ + (TO)[1] = (FROM)[1], \ + (TO)[2] = (FROM)[2], \ + (TO)[3] = (FROM)[3]) + +#define MAT3_SCALE_HVEC(RESULT_V,V,SCALE) \ + MAT3_SET_HVEC(RESULT_V, (V)[0]*(SCALE), (V)[1]*(SCALE), \ + (V)[2]*(SCALE), (V)[3]*(SCALE)) + +#define MAT3_ADD_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]+(V2)[0], (V1)[1]+(V2)[1], \ + (V1)[2]+(V2)[2], (V1)[3]+(V2)[3]) + +#define MAT3_SUB_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]-(V2)[0], (V1)[1]-(V2)[1], \ + (V1)[2]-(V2)[2], (V1)[3]-(V2)[3]) + +#define MAT3_MULT_HVEC(RESULT_V,V1,V2) \ + MAT3_SET_HVEC(RESULT_V, (V1)[0]*(V2)[0], (V1)[1]*(V2)[1], \ + (V1)[2]*(V2)[2], (V1)[3]*(V2)[3]) + +/* ------------------------------ Entries ------------------------------- */ + + +/* In MAT3geom.c */ +void MAT3direction_matrix (MAT3mat result_mat, MAT3mat mat); +int MAT3normal_matrix (MAT3mat result_mat, MAT3mat mat); +void MAT3rotate (MAT3mat result_mat, MAT3vec axis, double angle_in_radians); +void MAT3translate (MAT3mat result_mat, MAT3vec trans); +void MAT3scale (MAT3mat result_mat, MAT3vec scale); +void MAT3shear(MAT3mat result_mat, double xshear, double yshear); + +/* In MAT3mat.c */ +void MAT3identity(MAT3mat); +void MAT3zero(MAT3mat); +void MAT3copy (MAT3mat to, MAT3mat from); +void MAT3mult (MAT3mat result, MAT3mat, MAT3mat); +void MAT3transpose (MAT3mat result, MAT3mat); +int MAT3invert (MAT3mat result, MAT3mat); +void MAT3print (MAT3mat, FILE *fp); +void MAT3print_formatted (MAT3mat, FILE *fp, + char *title, char *head, char *format, char *tail); +extern int MAT3equal( void ); +extern double MAT3trace( void ); +extern int MAT3power( void ); +extern int MAT3column_reduce( void ); +extern int MAT3kernel_basis( void ); + +/* In MAT3vec.c */ +void MAT3mult_vec(MAT3vec result_vec, MAT3vec vec, MAT3mat mat); +int MAT3mult_hvec (MAT3hvec result_vec, MAT3hvec vec, MAT3mat mat, int normalize); +void MAT3cross_product(MAT3vec result,MAT3vec,MAT3vec); +void MAT3perp_vec(MAT3vec result_vec, MAT3vec vec, int is_unit); + +#endif /* MAT3_HAS_BEEN_INCLUDED */ + diff --git a/Tri2obj/polar.c b/Tri2obj/polar.c new file mode 100644 index 000000000..fae264766 --- /dev/null +++ b/Tri2obj/polar.c @@ -0,0 +1,124 @@ +/************************************************************************** + * polar.c -- routines to deal with polar math and transformations + * + * Written by Curtis Olson, started June 1997. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#include +#include + +#include +#include + + +/* we can save these values between calls for efficiency */ +static double st, ct, sp, cp; + + +/* Convert a polar coordinate to a cartesian coordinate. Lon and Lat + * must be specified in radians. The FG convention is for distances + * to be specified in meters */ +struct fgCartesianPoint fgPolarToCart(double lon, double lat, double radius) { + struct fgCartesianPoint pnew; + + pnew.x = cos(lon) * cos(lat) * radius; + pnew.y = sin(lon) * cos(lat) * radius; + pnew.z = sin(lat) * radius; + + return(pnew); +} + + +/* Precalculate as much as possible so we can do a batch of transforms + * through the same angles, will rotates a cartesian point about the + * center of the earth by Theta (longitude axis) and Phi (latitude + * axis) */ + +/* Here are the unoptimized transformation equations + + x' = cos(Phi) * cos(Theta) * x + cos(Phi) * sin(Theta) * y + + sin(Phi) * z + y' = -sin(Theta) * x + cos(Theta) * y + z' = -sin(Phi) * sin(Theta) * y - sin(Phi) * cos(Theta) * x + + cos(Phi) * z; + + */ +void fgRotateBatchInit(double Theta, double Phi) { + printf("Theta = %.3f, Phi = %.3f\n", Theta, Phi); + + st = sin(Theta); + ct = cos(Theta); + sp = sin(-Phi); + cp = cos(-Phi); +} + +/* Rotates a cartesian point about the center of the earth by Theta + * (longitude axis) and Phi (latitude axis) */ +struct fgCartesianPoint fgRotateCartesianPoint(struct fgCartesianPoint p) { + struct fgCartesianPoint p1, p2; + + /* printf("start = %.3f %.3f %.3f\n", p.x, p.y, p.z); */ + + /* rotate about the z axis */ + p1.x = ct * p.x - st * p.y; + p1.y = st * p.x + ct * p.y; + p1.z = p.z; + + /* printf("step 1 = %.3f %.3f %.3f\n", p1.x, p1.y, p1.z); */ + + /* rotate new point about y axis */ + p2.x = cp * p1.x + sp * p1.z; + p2.y = p1.y; + p2.z = cp * p1.z - sp * p1.x; + + /* printf("cp = %.5f, sp = %.5f\n", cp, sp); */ + /* printf("(1) = %.5f, (2) = %.5f\n", cp * p1.z, sp * p1.x); */ + + /* printf("step 2 = %.3f %.3f %.3f\n", p2.x, p2.y, p2.z); */ + + return(p2); +} + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:22:16 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.5 1998/01/27 00:48:00 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.4 1998/01/19 19:27:12 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.3 1997/12/15 23:54:54 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.2 1997/07/31 22:52:27 curt + * Working on redoing internal coordinate systems & scenery transformations. + * + * Revision 1.1 1997/07/07 21:02:36 curt + * Initial revision. + * */ diff --git a/Tri2obj/polar.h b/Tri2obj/polar.h new file mode 100644 index 000000000..fc54a77c5 --- /dev/null +++ b/Tri2obj/polar.h @@ -0,0 +1,93 @@ +/************************************************************************** + * polar.h -- routines to deal with polar math and transformations + * + * Written by Curtis Olson, started June 1997. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#ifndef _POLAR_H +#define _POLAR_H + + +#include + + +/* Convert a polar coordinate to a cartesian coordinate. Lon and Lat + * must be specified in radians. The FG convention is for distances + * to be specified in meters */ +struct fgCartesianPoint fgPolarToCart(double lon, double lat, double radius); + + +/* Precalculate as much as possible so we can do a batch of transforms + * through the same angles, will rotates a cartesian point about the + * center of the earth by Theta (longitude axis) and Phi (latitude + * axis) */ + +/* Here are the unoptimized transformation equations + + x' = cos(Phi) * cos(Theta) * x + cos(Phi) * sin(Theta) * y + + sin(Phi) * z + y' = -sin(Theta) * x + cos(Theta) * y + z' = -sin(Phi) * sin(Theta) * y - sin(Phi) * cos(Theta) * x + + cos(Phi) * z; + + */ +void fgRotateBatchInit(double Theta, double Phi); + + +/* Rotates a cartesian point about the center of the earth by Theta + * (longitude axis) and Phi (latitude axis) */ +struct fgCartesianPoint fgRotateCartesianPoint(struct fgCartesianPoint p); + + +#endif /* _POLAR_H */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:22:17 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.7 1998/01/27 00:48:00 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.6 1998/01/22 02:59:39 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * + * Revision 1.5 1998/01/19 19:27:13 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.4 1997/12/15 23:54:55 curt + * Add xgl wrappers for debugging. + * Generate terrain normals on the fly. + * + * Revision 1.3 1997/07/31 22:52:28 curt + * Working on redoing internal coordinate systems & scenery transformations. + * + * Revision 1.2 1997/07/23 21:52:21 curt + * Put comments around the text after an #endif for increased portability. + * + * Revision 1.1 1997/07/07 21:02:37 curt + * Initial revision. + * + */ diff --git a/Tri2obj/tri2obj.c b/Tri2obj/tri2obj.c index e44f5559d..fb0f8ddb2 100644 --- a/Tri2obj/tri2obj.c +++ b/Tri2obj/tri2obj.c @@ -34,10 +34,11 @@ #include #include -#include -#include -#include -#include +#include + +#include "fg_geodesy.h" +#include "mat3.h" +#include "polar.h" int nodecount, tricount; @@ -639,9 +640,12 @@ int main(int argc, char **argv) { /* $Log$ -/* Revision 1.11 1998/03/03 16:01:00 curt -/* More c++ compile tweaks. +/* Revision 1.12 1998/04/08 23:22:18 curt +/* Adopted Gnu automake/autoconf system. /* + * Revision 1.11 1998/03/03 16:01:00 curt + * More c++ compile tweaks. + * * Revision 1.10 1998/01/31 00:41:27 curt * Made a few changes converting floats to doubles. * diff --git a/Triangle/Makefile b/Triangle/Makefile deleted file mode 100644 index cccdf2b1c..000000000 --- a/Triangle/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -# makefile for Triangle and Show Me -# -# Type "make" to compile Triangle and Show Me. -# -# After compiling, type "triangle -h" and "showme -h" to read instructions -# for using each of these programs. -# -# Type "make trilibrary" to compile Triangle as an object file (triangle.o). -# -# Type "make distclean" to delete all executable files. - -# SRC is the directory in which the C source files are, and BIN is the -# directory where you want to put the executable programs. By default, -# both are the current directory. - -SRC = ./ -BIN = ./ - -# CC should be set to the name of your favorite C compiler. - -CC = cc - -# CSWITCHES is a list of all switches passed to the C compiler. I strongly -# recommend using the best level of optimization. I also strongly -# recommend timing each level of optimization to see which is the -# best. For instance, on my DEC Alpha using DEC's optimizing compiler, -# the -O2 switch generates a notably faster version of Triangle than the -# -O3 switch. Go figure. -# -# By default, Triangle and Show Me use double precision floating point -# numbers. If you prefer single precision, use the -DSINGLE switch. -# Double precision uses more memory, but improves the resolution of -# the meshes you can generate with Triangle. It also reduces the -# likelihood of a floating exception due to overflow. Also, it is -# much faster than single precision on 64-bit architectures like the -# DEC Alpha. I recommend double precision unless you want to generate -# a mesh for which you do not have enough memory to use double precision. -# -# If yours is not a Unix system, use the -DNO_TIMER switch to eliminate the -# Unix-specific timer code. -# -# If you are modifying Triangle, I recommend using the -DSELF_CHECK switch -# while you are debugging. Defining the SELF_CHECK symbol causes -# Triangle to include self-checking code. Triangle will execute more -# slowly, however, so be sure to remove this switch before compiling a -# production version. -# -# If the size of the Triangle binary is important to you, you may wish to -# generate a reduced version of Triangle. The -DREDUCED switch gets rid -# of all features that are primarily of research interest. Specifically, -# defining the REDUCED symbol eliminates the -i, -F, -s, and -C switches. -# The -DCDT_ONLY switch gets rid of all meshing algorithms above and beyond -# constrained Delaunay triangulation. Specifically, defining the CDT_ONLY -# symbol eliminates the -r, -q, -a, -S, and -s switches. The REDUCED and -# CDT_ONLY symbols may be particularly attractive when Triangle is called -# by another program that does not need all of Triangle's features; in -# this case, these switches should appear as part of "TRILIBDEFS" below. -# -# On some systems, you may need to include -I/usr/local/include and/or -# -L/usr/local/lib in the compiler options to ensure that the X include -# files and libraries that Show Me needs are found. If you get errors -# like "Can't find include file X11/Xlib.h", you need the former switch. -# Try compiling without them first; add them if that fails. -# -# An example CSWITCHES line is: -# -# CSWITCHES = -O -DNO_TIMER -I/usr/local/include -L/usr/local/lib - -CSWITCHES = -O - -# TRILIBDEFS is a list of definitions used to compile an object code version -# of Triangle (triangle.o) to be called by another program. The file -# "triangle.h" contains detailed information on how to call triangle.o. -# -# The -DTRILIBRARY should always be used when compiling Triangle into an -# object file. -# -# An example TRILIBDEFS line is: -# -# TRILIBDEFS = -DTRILIBRARY -DREDUCED -DCDT_ONLY - -TRILIBDEFS = -DTRILIBRARY - -# RM should be set to the name of your favorite rm (file deletion program). - -RM = /bin/rm -f - -# The action starts here. - -all: $(BIN)triangle $(BIN)showme - -trilibrary: $(BIN)triangle.o $(BIN)tricall - -$(BIN)triangle: $(SRC)triangle.c - $(CC) $(CSWITCHES) -o $(BIN)triangle $(SRC)triangle.c -lm - -$(BIN)tricall: $(BIN)tricall.c $(BIN)triangle.o - $(CC) $(CSWITCHES) -o $(BIN)tricall $(SRC)tricall.c \ - $(BIN)triangle.o -lm - -$(BIN)triangle.o: $(SRC)triangle.c $(SRC)triangle.h - $(CC) $(CSWITCHES) $(TRILIBDEFS) -c -o $(BIN)triangle.o \ - $(SRC)triangle.c - -$(BIN)showme: $(SRC)showme.c - $(CC) $(CSWITCHES) -o $(BIN)showme $(SRC)showme.c -L/usr/X11R6/lib -lX11 - -clean: distclean - -distclean: - $(RM) $(BIN)triangle $(BIN)triangle.o $(BIN)showme diff --git a/Triangle/Makefile.am b/Triangle/Makefile.am new file mode 100644 index 000000000..99c292410 --- /dev/null +++ b/Triangle/Makefile.am @@ -0,0 +1,18 @@ +# DEFS is a list of definitions used to compile an object code version +# of Triangle (triangle.o) to be called by another program. The file +# "triangle.h" contains detailed information on how to call triangle.o. +# +# The -DTRILIBRARY should always be used when compiling Triangle into an +# object file. +# +# An example DEFS line is: +# +# DEFS = -DTRILIBRARY -DREDUCED -DCDT_ONLY + +DEFS += + +bin_PROGRAMS = triangle # showme + +triangle_SOURCES = triangle.c triangle.h + +# showme_SOURCES = showme.c diff --git a/Triangle/Makefile.in b/Triangle/Makefile.in new file mode 100644 index 000000000..eed70e754 --- /dev/null +++ b/Triangle/Makefile.in @@ -0,0 +1,333 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# DEFS is a list of definitions used to compile an object code version +# of Triangle (triangle.o) to be called by another program. The file +# "triangle.h" contains detailed information on how to call triangle.o. +# +# The -DTRILIBRARY should always be used when compiling Triangle into an +# object file. +# +# An example DEFS line is: +# +# DEFS = -DTRILIBRARY -DREDUCED -DCDT_ONLY + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +bin_PROGRAMS = triangle # showme + +triangle_SOURCES = triangle.c triangle.h +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../Simulator/Include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +triangle_OBJECTS = triangle.o +triangle_LDADD = $(LDADD) +triangle_DEPENDENCIES = +triangle_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/triangle.P +SOURCES = $(triangle_SOURCES) +OBJECTS = $(triangle_OBJECTS) + +all: Makefile $(PROGRAMS) + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Tools/Triangle/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +triangle: $(triangle_OBJECTS) $(triangle_DEPENDENCIES) + @rm -f triangle + $(LINK) $(triangle_LDFLAGS) $(triangle_OBJECTS) $(triangle_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Tools/Triangle + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Tools/Triangle/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binPROGRAMS + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +clean: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean + +distclean: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-libtool maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info dvi installcheck install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +DEFS += + +# showme_SOURCES = showme.c + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Triangle/depend b/Triangle/depend deleted file mode 100644 index 3293c1b40..000000000 --- a/Triangle/depend +++ /dev/null @@ -1,27 +0,0 @@ -showme.o: showme.c /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.7.2.1/include/stddef.h \ - /usr/include/X11/Xlib.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/linux/posix_types.h \ - /usr/include/asm/posix_types.h /usr/include/asm/types.h \ - /usr/include/sys/bitypes.h /usr/include/X11/X.h \ - /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h \ - /usr/include/X11/Xutil.h /usr/include/X11/Xatom.h -triangle.o: triangle.c /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.7.2.1/include/stddef.h \ - /usr/include/math.h /usr/include/huge_val.h /usr/include/endian.h \ - /usr/include/bytesex.h /usr/include/nan.h \ - /usr/lib/gcc-lib/i486-linux/2.7.2.1/include/float.h \ - /usr/include/values.h /usr/include/ieee754.h \ - /usr/include/i386/ieeefp.h /usr/include/ieee854.h \ - /usr/include/sys/time.h /usr/include/linux/types.h \ - /usr/include/linux/posix_types.h /usr/include/asm/posix_types.h \ - /usr/include/asm/types.h /usr/include/linux/time.h \ - /usr/include/time.h /usr/include/sys/types.h \ - /usr/include/sys/bitypes.h -tricall.o: tricall.c /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h \ - /usr/include/_G_config.h triangle.h diff --git a/Triangle/triangle.doc b/Triangle/triangle.doc new file mode 100644 index 000000000..28b633978 --- /dev/null +++ b/Triangle/triangle.doc @@ -0,0 +1,817 @@ +Triangle +A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. +Version 1.3 + +Copyright 1996 Jonathan Richard Shewchuk (bugs/comments to jrs@cs.cmu.edu) +School of Computer Science / Carnegie Mellon University +5000 Forbes Avenue / Pittsburgh, Pennsylvania 15213-3891 +Created as part of the Archimedes project (tools for parallel FEM). +Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship. +There is no warranty whatsoever. Use at your own risk. +This executable is compiled for double precision arithmetic. + + +Triangle generates exact Delaunay triangulations, constrained Delaunay +triangulations, and quality conforming Delaunay triangulations. The latter +can be generated with no small angles, and are thus suitable for finite +element analysis. If no command line switches are specified, your .node +input file will be read, and the Delaunay triangulation will be returned in +.node and .ele output files. The command syntax is: + +triangle [-prq__a__AcevngBPNEIOXzo_YS__iFlsCQVh] input_file + +Underscores indicate that numbers may optionally follow certain switches; +do not leave any space between a switch and its numeric parameter. +input_file must be a file with extension .node, or extension .poly if the +-p switch is used. If -r is used, you must supply .node and .ele files, +and possibly a .poly file and .area file as well. The formats of these +files are described below. + +Command Line Switches: + + -p Reads a Planar Straight Line Graph (.poly file), which can specify + points, segments, holes, and regional attributes and area + constraints. Will generate a constrained Delaunay triangulation + fitting the input; or, if -s, -q, or -a is used, a conforming + Delaunay triangulation. If -p is not used, Triangle reads a .node + file by default. + -r Refines a previously generated mesh. The mesh is read from a .node + file and an .ele file. If -p is also used, a .poly file is read + and used to constrain edges in the mesh. Further details on + refinement are given below. + -q Quality mesh generation by Jim Ruppert's Delaunay refinement + algorithm. Adds points to the mesh to ensure that no angles + smaller than 20 degrees occur. An alternative minimum angle may be + specified after the `q'. If the minimum angle is 20.7 degrees or + smaller, the triangulation algorithm is theoretically guaranteed to + terminate (assuming infinite precision arithmetic - Triangle may + fail to terminate if you run out of precision). In practice, the + algorithm often succeeds for minimum angles up to 33.8 degrees. + For highly refined meshes, however, it may be necessary to reduce + the minimum angle to well below 20 to avoid problems associated + with insufficient floating-point precision. The specified angle + may include a decimal point. + -a Imposes a maximum triangle area. If a number follows the `a', no + triangle will be generated whose area is larger than that number. + If no number is specified, an .area file (if -r is used) or .poly + file (if -r is not used) specifies a number of maximum area + constraints. An .area file contains a separate area constraint for + each triangle, and is useful for refining a finite element mesh + based on a posteriori error estimates. A .poly file can optionally + contain an area constraint for each segment-bounded region, thereby + enforcing triangle densities in a first triangulation. You can + impose both a fixed area constraint and a varying area constraint + by invoking the -a switch twice, once with and once without a + number following. Each area specified may include a decimal point. + -A Assigns an additional attribute to each triangle that identifies + what segment-bounded region each triangle belongs to. Attributes + are assigned to regions by the .poly file. If a region is not + explicitly marked by the .poly file, triangles in that region are + assigned an attribute of zero. The -A switch has an effect only + when the -p switch is used and the -r switch is not. + -c Creates segments on the convex hull of the triangulation. If you + are triangulating a point set, this switch causes a .poly file to + be written, containing all edges in the convex hull. (By default, + a .poly file is written only if a .poly file is read.) If you are + triangulating a PSLG, this switch specifies that the interior of + the convex hull of the PSLG should be triangulated. If you do not + use this switch when triangulating a PSLG, it is assumed that you + have identified the region to be triangulated by surrounding it + with segments of the input PSLG. Beware: if you are not careful, + this switch can cause the introduction of an extremely thin angle + between a PSLG segment and a convex hull segment, which can cause + overrefinement or failure if Triangle runs out of precision. If + you are refining a mesh, the -c switch works differently; it + generates the set of boundary edges of the mesh, rather than the + convex hull. + -e Outputs (to an .edge file) a list of edges of the triangulation. + -v Outputs the Voronoi diagram associated with the triangulation. + Does not attempt to detect degeneracies. + -n Outputs (to a .neigh file) a list of triangles neighboring each + triangle. + -g Outputs the mesh to an Object File Format (.off) file, suitable for + viewing with the Geometry Center's Geomview package. + -B No boundary markers in the output .node, .poly, and .edge output + files. See the detailed discussion of boundary markers below. + -P No output .poly file. Saves disk space, but you lose the ability + to impose segment constraints on later refinements of the mesh. + -N No output .node file. + -E No output .ele file. + -I No iteration numbers. Suppresses the output of .node and .poly + files, so your input files won't be overwritten. (If your input is + a .poly file only, a .node file will be written.) Cannot be used + with the -r switch, because that would overwrite your input .ele + file. Shouldn't be used with the -s, -q, or -a switch if you are + using a .node file for input, because no .node file will be + written, so there will be no record of any added points. + -O No holes. Ignores the holes in the .poly file. + -X No exact arithmetic. Normally, Triangle uses exact floating-point + arithmetic for certain tests if it thinks the inexact tests are not + accurate enough. Exact arithmetic ensures the robustness of the + triangulation algorithms, despite floating-point roundoff error. + Disabling exact arithmetic with the -X switch will cause a small + improvement in speed and create the possibility (albeit small) that + Triangle will fail to produce a valid mesh. Not recommended. + -z Numbers all items starting from zero (rather than one). Note that + this switch is normally overrided by the value used to number the + first point of the input .node or .poly file. However, this switch + is useful when calling Triangle from another program. + -o2 Generates second-order subparametric elements with six nodes each. + -Y No new points on the boundary. This switch is useful when the mesh + boundary must be preserved so that it conforms to some adjacent + mesh. Be forewarned that you will probably sacrifice some of the + quality of the mesh; Triangle will try, but the resulting mesh may + contain triangles of poor aspect ratio. Works well if all the + boundary points are closely spaced. Specify this switch twice + (`-YY') to prevent all segment splitting, including internal + boundaries. + -S Specifies the maximum number of Steiner points (points that are not + in the input, but are added to meet the constraints of minimum + angle and maximum area). The default is to allow an unlimited + number. If you specify this switch with no number after it, + the limit is set to zero. Triangle always adds points at segment + intersections, even if it needs to use more points than the limit + you set. When Triangle inserts segments by splitting (-s), it + always adds enough points to ensure that all the segments appear in + the triangulation, again ignoring the limit. Be forewarned that + the -S switch may result in a conforming triangulation that is not + truly Delaunay, because Triangle may be forced to stop adding + points when the mesh is in a state where a segment is non-Delaunay + and needs to be split. If so, Triangle will print a warning. + -i Uses an incremental rather than divide-and-conquer algorithm to + form a Delaunay triangulation. Try it if the divide-and-conquer + algorithm fails. + -F Uses Steven Fortune's sweepline algorithm to form a Delaunay + triangulation. Warning: does not use exact arithmetic for all + calculations. An exact result is not guaranteed. + -l Uses only vertical cuts in the divide-and-conquer algorithm. By + default, Triangle uses alternating vertical and horizontal cuts, + which usually improve the speed except with point sets that are + small or short and wide. This switch is primarily of theoretical + interest. + -s Specifies that segments should be forced into the triangulation by + recursively splitting them at their midpoints, rather than by + generating a constrained Delaunay triangulation. Segment splitting + is true to Ruppert's original algorithm, but can create needlessly + small triangles near external small features. + -C Check the consistency of the final mesh. Uses exact arithmetic for + checking, even if the -X switch is used. Useful if you suspect + Triangle is buggy. + -Q Quiet: Suppresses all explanation of what Triangle is doing, unless + an error occurs. + -V Verbose: Gives detailed information about what Triangle is doing. + Add more `V's for increasing amount of detail. `-V' gives + information on algorithmic progress and more detailed statistics. + `-VV' gives point-by-point details, and will print so much that + Triangle will run much more slowly. `-VVV' gives information only + a debugger could love. + -h Help: Displays these instructions. + +Definitions: + + A Delaunay triangulation of a point set is a triangulation whose vertices + are the point set, having the property that no point in the point set + falls in the interior of the circumcircle (circle that passes through all + three vertices) of any triangle in the triangulation. + + A Voronoi diagram of a point set is a subdivision of the plane into + polygonal regions (some of which may be infinite), where each region is + the set of points in the plane that are closer to some input point than + to any other input point. (The Voronoi diagram is the geometric dual of + the Delaunay triangulation.) + + A Planar Straight Line Graph (PSLG) is a collection of points and + segments. Segments are simply edges, whose endpoints are points in the + PSLG. The file format for PSLGs (.poly files) is described below. + + A constrained Delaunay triangulation of a PSLG is similar to a Delaunay + triangulation, but each PSLG segment is present as a single edge in the + triangulation. (A constrained Delaunay triangulation is not truly a + Delaunay triangulation.) + + A conforming Delaunay triangulation of a PSLG is a true Delaunay + triangulation in which each PSLG segment may have been subdivided into + several edges by the insertion of additional points. These inserted + points are necessary to allow the segments to exist in the mesh while + maintaining the Delaunay property. + +File Formats: + + All files may contain comments prefixed by the character '#'. Points, + triangles, edges, holes, and maximum area constraints must be numbered + consecutively, starting from either 1 or 0. Whichever you choose, all + input files must be consistent; if the nodes are numbered from 1, so must + be all other objects. Triangle automatically detects your choice while + reading the .node (or .poly) file. (When calling Triangle from another + program, use the -z switch if you wish to number objects from zero.) + Examples of these file formats are given below. + + .node files: + First line: <# of points> <# of attributes> + <# of boundary markers (0 or 1)> + Remaining lines: [attributes] [boundary marker] + + The attributes, which are typically floating-point values of physical + quantities (such as mass or conductivity) associated with the nodes of + a finite element mesh, are copied unchanged to the output mesh. If -s, + -q, or -a is selected, each new Steiner point added to the mesh will + have attributes assigned to it by linear interpolation. + + If the fourth entry of the first line is `1', the last column of the + remainder of the file is assumed to contain boundary markers. Boundary + markers are used to identify boundary points and points resting on PSLG + segments; a complete description appears in a section below. The .node + file produced by Triangle will contain boundary markers in the last + column unless they are suppressed by the -B switch. + + .ele files: + First line: <# of triangles> <# of attributes> + Remaining lines: ... [attributes] + + Points are indices into the corresponding .node file. The first three + points are the corners, and are listed in counterclockwise order around + each triangle. (The remaining points, if any, depend on the type of + finite element used.) The attributes are just like those of .node + files. Because there is no simple mapping from input to output + triangles, an attempt is made to interpolate attributes, which may + result in a good deal of diffusion of attributes among nearby triangles + as the triangulation is refined. Diffusion does not occur across + segments, so attributes used to identify segment-bounded regions remain + intact. In output .ele files, all triangles have three points each + unless the -o2 switch is used, in which case they have six, and the + fourth, fifth, and sixth points lie on the midpoints of the edges + opposite the first, second, and third corners. + + .poly files: + First line: <# of points> <# of attributes> + <# of boundary markers (0 or 1)> + Following lines: [attributes] [boundary marker] + One line: <# of segments> <# of boundary markers (0 or 1)> + Following lines: [boundary marker] + One line: <# of holes> + Following lines: + Optional line: <# of regional attributes and/or area constraints> + Optional following lines: + + A .poly file represents a PSLG, as well as some additional information. + The first section lists all the points, and is identical to the format + of .node files. <# of points> may be set to zero to indicate that the + points are listed in a separate .node file; .poly files produced by + Triangle always have this format. This has the advantage that a point + set may easily be triangulated with or without segments. (The same + effect can be achieved, albeit using more disk space, by making a copy + of the .poly file with the extension .node; all sections of the file + but the first are ignored.) + + The second section lists the segments. Segments are edges whose + presence in the triangulation is enforced. Each segment is specified + by listing the indices of its two endpoints. This means that you must + include its endpoints in the point list. If -s, -q, and -a are not + selected, Triangle will produce a constrained Delaunay triangulation, + in which each segment appears as a single edge in the triangulation. + If -q or -a is selected, Triangle will produce a conforming Delaunay + triangulation, in which segments may be subdivided into smaller edges. + Each segment, like each point, may have a boundary marker. + + The third section lists holes (and concavities, if -c is selected) in + the triangulation. Holes are specified by identifying a point inside + each hole. After the triangulation is formed, Triangle creates holes + by eating triangles, spreading out from each hole point until its + progress is blocked by PSLG segments; you must be careful to enclose + each hole in segments, or your whole triangulation may be eaten away. + If the two triangles abutting a segment are eaten, the segment itself + is also eaten. Do not place a hole directly on a segment; if you do, + Triangle will choose one side of the segment arbitrarily. + + The optional fourth section lists regional attributes (to be assigned + to all triangles in a region) and regional constraints on the maximum + triangle area. Triangle will read this section only if the -A switch + is used or the -a switch is used without a number following it, and the + -r switch is not used. Regional attributes and area constraints are + propagated in the same manner as holes; you specify a point for each + attribute and/or constraint, and the attribute and/or constraint will + affect the whole region (bounded by segments) containing the point. If + two values are written on a line after the x and y coordinate, the + former is assumed to be a regional attribute (but will only be applied + if the -A switch is selected), and the latter is assumed to be a + regional area constraint (but will only be applied if the -a switch is + selected). You may also specify just one value after the coordinates, + which can serve as both an attribute and an area constraint, depending + on the choice of switches. If you are using the -A and -a switches + simultaneously and wish to assign an attribute to some region without + imposing an area constraint, use a negative maximum area. + + When a triangulation is created from a .poly file, you must either + enclose the entire region to be triangulated in PSLG segments, or + use the -c switch, which encloses the convex hull of the input point + set. If you do not use the -c switch, Triangle will eat all triangles + on the outer boundary that are not protected by segments; if you are + not careful, your whole triangulation may be eaten away. If you do + use the -c switch, you can still produce concavities by appropriate + placement of holes just inside the convex hull. + + An ideal PSLG has no intersecting segments, nor any points that lie + upon segments (except, of course, the endpoints of each segment.) You + aren't required to make your .poly files ideal, but you should be aware + of what can go wrong. Segment intersections are relatively safe - + Triangle will calculate the intersection points for you and add them to + the triangulation - as long as your machine's floating-point precision + doesn't become a problem. You are tempting the fates if you have three + segments that cross at the same location, and expect Triangle to figure + out where the intersection point is. Thanks to floating-point roundoff + error, Triangle will probably decide that the three segments intersect + at three different points, and you will find a minuscule triangle in + your output - unless Triangle tries to refine the tiny triangle, uses + up the last bit of machine precision, and fails to terminate at all. + You're better off putting the intersection point in the input files, + and manually breaking up each segment into two. Similarly, if you + place a point at the middle of a segment, and hope that Triangle will + break up the segment at that point, you might get lucky. On the other + hand, Triangle might decide that the point doesn't lie precisely on the + line, and you'll have a needle-sharp triangle in your output - or a lot + of tiny triangles if you're generating a quality mesh. + + When Triangle reads a .poly file, it also writes a .poly file, which + includes all edges that are part of input segments. If the -c switch + is used, the output .poly file will also include all of the edges on + the convex hull. Hence, the output .poly file is useful for finding + edges associated with input segments and setting boundary conditions in + finite element simulations. More importantly, you will need it if you + plan to refine the output mesh, and don't want segments to be missing + in later triangulations. + + .area files: + First line: <# of triangles> + Following lines: + + An .area file associates with each triangle a maximum area that is used + for mesh refinement. As with other file formats, every triangle must + be represented, and they must be numbered consecutively. A triangle + may be left unconstrained by assigning it a negative maximum area. + + .edge files: + First line: <# of edges> <# of boundary markers (0 or 1)> + Following lines: [boundary marker] + + Endpoints are indices into the corresponding .node file. Triangle can + produce .edge files (use the -e switch), but cannot read them. The + optional column of boundary markers is suppressed by the -B switch. + + In Voronoi diagrams, one also finds a special kind of edge that is an + infinite ray with only one endpoint. For these edges, a different + format is used: + + -1 + + The `direction' is a floating-point vector that indicates the direction + of the infinite ray. + + .neigh files: + First line: <# of triangles> <# of neighbors per triangle (always 3)> + Following lines: + + Neighbors are indices into the corresponding .ele file. An index of -1 + indicates a mesh boundary, and therefore no neighbor. Triangle can + produce .neigh files (use the -n switch), but cannot read them. + + The first neighbor of triangle i is opposite the first corner of + triangle i, and so on. + +Boundary Markers: + + Boundary markers are tags used mainly to identify which output points and + edges are associated with which PSLG segment, and to identify which + points and edges occur on a boundary of the triangulation. A common use + is to determine where boundary conditions should be applied to a finite + element mesh. You can prevent boundary markers from being written into + files produced by Triangle by using the -B switch. + + The boundary marker associated with each segment in an output .poly file + or edge in an output .edge file is chosen as follows: + - If an output edge is part or all of a PSLG segment with a nonzero + boundary marker, then the edge is assigned the same marker. + - Otherwise, if the edge occurs on a boundary of the triangulation + (including boundaries of holes), then the edge is assigned the marker + one (1). + - Otherwise, the edge is assigned the marker zero (0). + The boundary marker associated with each point in an output .node file is + chosen as follows: + - If a point is assigned a nonzero boundary marker in the input file, + then it is assigned the same marker in the output .node file. + - Otherwise, if the point lies on a PSLG segment (including the + segment's endpoints) with a nonzero boundary marker, then the point + is assigned the same marker. If the point lies on several such + segments, one of the markers is chosen arbitrarily. + - Otherwise, if the point occurs on a boundary of the triangulation, + then the point is assigned the marker one (1). + - Otherwise, the point is assigned the marker zero (0). + + If you want Triangle to determine for you which points and edges are on + the boundary, assign them the boundary marker zero (or use no markers at + all) in your input files. Alternatively, you can mark some of them and + leave others marked zero, allowing Triangle to label them. + +Triangulation Iteration Numbers: + + Because Triangle can read and refine its own triangulations, input + and output files have iteration numbers. For instance, Triangle might + read the files mesh.3.node, mesh.3.ele, and mesh.3.poly, refine the + triangulation, and output the files mesh.4.node, mesh.4.ele, and + mesh.4.poly. Files with no iteration number are treated as if + their iteration number is zero; hence, Triangle might read the file + points.node, triangulate it, and produce the files points.1.node and + points.1.ele. + + Iteration numbers allow you to create a sequence of successively finer + meshes suitable for multigrid methods. They also allow you to produce a + sequence of meshes using error estimate-driven mesh refinement. + + If you're not using refinement or quality meshing, and you don't like + iteration numbers, use the -I switch to disable them. This switch will + also disable output of .node and .poly files to prevent your input files + from being overwritten. (If the input is a .poly file that contains its + own points, a .node file will be written.) + +Examples of How to Use Triangle: + + `triangle dots' will read points from dots.node, and write their Delaunay + triangulation to dots.1.node and dots.1.ele. (dots.1.node will be + identical to dots.node.) `triangle -I dots' writes the triangulation to + dots.ele instead. (No additional .node file is needed, so none is + written.) + + `triangle -pe object.1' will read a PSLG from object.1.poly (and possibly + object.1.node, if the points are omitted from object.1.poly) and write + their constrained Delaunay triangulation to object.2.node and + object.2.ele. The segments will be copied to object.2.poly, and all + edges will be written to object.2.edge. + + `triangle -pq31.5a.1 object' will read a PSLG from object.poly (and + possibly object.node), generate a mesh whose angles are all greater than + 31.5 degrees and whose triangles all have area smaller than 0.1, and + write the mesh to object.1.node and object.1.ele. Each segment may have + been broken up into multiple edges; the resulting constrained edges are + written to object.1.poly. + + Here is a sample file `box.poly' describing a square with a square hole: + + # A box with eight points in 2D, no attributes, one boundary marker. + 8 2 0 1 + # Outer box has these vertices: + 1 0 0 0 + 2 0 3 0 + 3 3 0 0 + 4 3 3 33 # A special marker for this point. + # Inner square has these vertices: + 5 1 1 0 + 6 1 2 0 + 7 2 1 0 + 8 2 2 0 + # Five segments with boundary markers. + 5 1 + 1 1 2 5 # Left side of outer box. + 2 5 7 0 # Segments 2 through 5 enclose the hole. + 3 7 8 0 + 4 8 6 10 + 5 6 5 0 + # One hole in the middle of the inner square. + 1 + 1 1.5 1.5 + + Note that some segments are missing from the outer square, so one must + use the `-c' switch. After `triangle -pqc box.poly', here is the output + file `box.1.node', with twelve points. The last four points were added + to meet the angle constraint. Points 1, 2, and 9 have markers from + segment 1. Points 6 and 8 have markers from segment 4. All the other + points but 4 have been marked to indicate that they lie on a boundary. + + 12 2 0 1 + 1 0 0 5 + 2 0 3 5 + 3 3 0 1 + 4 3 3 33 + 5 1 1 1 + 6 1 2 10 + 7 2 1 1 + 8 2 2 10 + 9 0 1.5 5 + 10 1.5 0 1 + 11 3 1.5 1 + 12 1.5 3 1 + # Generated by triangle -pqc box.poly + + Here is the output file `box.1.ele', with twelve triangles. + + 12 3 0 + 1 5 6 9 + 2 10 3 7 + 3 6 8 12 + 4 9 1 5 + 5 6 2 9 + 6 7 3 11 + 7 11 4 8 + 8 7 5 10 + 9 12 2 6 + 10 8 7 11 + 11 5 1 10 + 12 8 4 12 + # Generated by triangle -pqc box.poly + + Here is the output file `box.1.poly'. Note that segments have been added + to represent the convex hull, and some segments have been split by newly + added points. Note also that <# of points> is set to zero to indicate + that the points should be read from the .node file. + + 0 2 0 1 + 12 1 + 1 1 9 5 + 2 5 7 1 + 3 8 7 1 + 4 6 8 10 + 5 5 6 1 + 6 3 10 1 + 7 4 11 1 + 8 2 12 1 + 9 9 2 5 + 10 10 1 1 + 11 11 3 1 + 12 12 4 1 + 1 + 1 1.5 1.5 + # Generated by triangle -pqc box.poly + +Refinement and Area Constraints: + + The -r switch causes a mesh (.node and .ele files) to be read and + refined. If the -p switch is also used, a .poly file is read and used to + specify edges that are constrained and cannot be eliminated (although + they can be divided into smaller edges) by the refinement process. + + When you refine a mesh, you generally want to impose tighter quality + constraints. One way to accomplish this is to use -q with a larger + angle, or -a followed by a smaller area than you used to generate the + mesh you are refining. Another way to do this is to create an .area + file, which specifies a maximum area for each triangle, and use the -a + switch (without a number following). Each triangle's area constraint is + applied to that triangle. Area constraints tend to diffuse as the mesh + is refined, so if there are large variations in area constraint between + adjacent triangles, you may not get the results you want. + + If you are refining a mesh composed of linear (three-node) elements, the + output mesh will contain all the nodes present in the input mesh, in the + same order, with new nodes added at the end of the .node file. However, + there is no guarantee that each output element is contained in a single + input element. Often, output elements will overlap two input elements, + and input edges are not present in the output mesh. Hence, a sequence of + refined meshes will form a hierarchy of nodes, but not a hierarchy of + elements. If you a refining a mesh of higher-order elements, the + hierarchical property applies only to the nodes at the corners of an + element; other nodes may not be present in the refined mesh. + + It is important to understand that maximum area constraints in .poly + files are handled differently from those in .area files. A maximum area + in a .poly file applies to the whole (segment-bounded) region in which a + point falls, whereas a maximum area in an .area file applies to only one + triangle. Area constraints in .poly files are used only when a mesh is + first generated, whereas area constraints in .area files are used only to + refine an existing mesh, and are typically based on a posteriori error + estimates resulting from a finite element simulation on that mesh. + + `triangle -rq25 object.1' will read object.1.node and object.1.ele, then + refine the triangulation to enforce a 25 degree minimum angle, and then + write the refined triangulation to object.2.node and object.2.ele. + + `triangle -rpaa6.2 z.3' will read z.3.node, z.3.ele, z.3.poly, and + z.3.area. After reconstructing the mesh and its segments, Triangle will + refine the mesh so that no triangle has area greater than 6.2, and + furthermore the triangles satisfy the maximum area constraints in + z.3.area. The output is written to z.4.node, z.4.ele, and z.4.poly. + + The sequence `triangle -qa1 x', `triangle -rqa.3 x.1', `triangle -rqa.1 + x.2' creates a sequence of successively finer meshes x.1, x.2, and x.3, + suitable for multigrid. + +Convex Hulls and Mesh Boundaries: + + If the input is a point set (rather than a PSLG), Triangle produces its + convex hull as a by-product in the output .poly file if you use the -c + switch. There are faster algorithms for finding a two-dimensional convex + hull than triangulation, of course, but this one comes for free. If the + input is an unconstrained mesh (you are using the -r switch but not the + -p switch), Triangle produces a list of its boundary edges (including + hole boundaries) as a by-product if you use the -c switch. + +Voronoi Diagrams: + + The -v switch produces a Voronoi diagram, in files suffixed .v.node and + .v.edge. For example, `triangle -v points' will read points.node, + produce its Delaunay triangulation in points.1.node and points.1.ele, + and produce its Voronoi diagram in points.1.v.node and points.1.v.edge. + The .v.node file contains a list of all Voronoi vertices, and the .v.edge + file contains a list of all Voronoi edges, some of which may be infinite + rays. (The choice of filenames makes it easy to run the set of Voronoi + vertices through Triangle, if so desired.) + + This implementation does not use exact arithmetic to compute the Voronoi + vertices, and does not check whether neighboring vertices are identical. + Be forewarned that if the Delaunay triangulation is degenerate or + near-degenerate, the Voronoi diagram may have duplicate points, crossing + edges, or infinite rays whose direction vector is zero. Also, if you + generate a constrained (as opposed to conforming) Delaunay triangulation, + or if the triangulation has holes, the corresponding Voronoi diagram is + likely to have crossing edges and unlikely to make sense. + +Mesh Topology: + + You may wish to know which triangles are adjacent to a certain Delaunay + edge in an .edge file, which Voronoi regions are adjacent to a certain + Voronoi edge in a .v.edge file, or which Voronoi regions are adjacent to + each other. All of this information can be found by cross-referencing + output files with the recollection that the Delaunay triangulation and + the Voronoi diagrams are planar duals. + + Specifically, edge i of an .edge file is the dual of Voronoi edge i of + the corresponding .v.edge file, and is rotated 90 degrees counterclock- + wise from the Voronoi edge. Triangle j of an .ele file is the dual of + vertex j of the corresponding .v.node file; and Voronoi region k is the + dual of point k of the corresponding .node file. + + Hence, to find the triangles adjacent to a Delaunay edge, look at the + vertices of the corresponding Voronoi edge; their dual triangles are on + the left and right of the Delaunay edge, respectively. To find the + Voronoi regions adjacent to a Voronoi edge, look at the endpoints of the + corresponding Delaunay edge; their dual regions are on the right and left + of the Voronoi edge, respectively. To find which Voronoi regions are + adjacent to each other, just read the list of Delaunay edges. + +Statistics: + + After generating a mesh, Triangle prints a count of the number of points, + triangles, edges, boundary edges, and segments in the output mesh. If + you've forgotten the statistics for an existing mesh, the -rNEP switches + (or -rpNEP if you've got a .poly file for the existing mesh) will + regenerate these statistics without writing any output. + + The -V switch produces extended statistics, including a rough estimate + of memory use and a histogram of triangle aspect ratios and angles in the + mesh. + +Exact Arithmetic: + + Triangle uses adaptive exact arithmetic to perform what computational + geometers call the `orientation' and `incircle' tests. If the floating- + point arithmetic of your machine conforms to the IEEE 754 standard (as + most workstations do), and does not use extended precision internal + registers, then your output is guaranteed to be an absolutely true + Delaunay or conforming Delaunay triangulation, roundoff error + notwithstanding. The word `adaptive' implies that these arithmetic + routines compute the result only to the precision necessary to guarantee + correctness, so they are usually nearly as fast as their approximate + counterparts. The exact tests can be disabled with the -X switch. On + most inputs, this switch will reduce the computation time by about eight + percent - it's not worth the risk. There are rare difficult inputs + (having many collinear and cocircular points), however, for which the + difference could be a factor of two. These are precisely the inputs most + likely to cause errors if you use the -X switch. + + Unfortunately, these routines don't solve every numerical problem. Exact + arithmetic is not used to compute the positions of points, because the + bit complexity of point coordinates would grow without bound. Hence, + segment intersections aren't computed exactly; in very unusual cases, + roundoff error in computing an intersection point might actually lead to + an inverted triangle and an invalid triangulation. (This is one reason + to compute your own intersection points in your .poly files.) Similarly, + exact arithmetic is not used to compute the vertices of the Voronoi + diagram. + + Underflow and overflow can also cause difficulties; the exact arithmetic + routines do not ameliorate out-of-bounds exponents, which can arise + during the orientation and incircle tests. As a rule of thumb, you + should ensure that your input values are within a range such that their + third powers can be taken without underflow or overflow. Underflow can + silently prevent the tests from being performed exactly, while overflow + will typically cause a floating exception. + +Calling Triangle from Another Program: + + Read the file triangle.h for details. + +Troubleshooting: + + Please read this section before mailing me bugs. + + `My output mesh has no triangles!' + + If you're using a PSLG, you've probably failed to specify a proper set + of bounding segments, or forgotten to use the -c switch. Or you may + have placed a hole badly. To test these possibilities, try again with + the -c and -O switches. Alternatively, all your input points may be + collinear, in which case you can hardly expect to triangulate them. + + `Triangle doesn't terminate, or just crashes.' + + Bad things can happen when triangles get so small that the distance + between their vertices isn't much larger than the precision of your + machine's arithmetic. If you've compiled Triangle for single-precision + arithmetic, you might do better by recompiling it for double-precision. + Then again, you might just have to settle for more lenient constraints + on the minimum angle and the maximum area than you had planned. + + You can minimize precision problems by ensuring that the origin lies + inside your point set, or even inside the densest part of your + mesh. On the other hand, if you're triangulating an object whose x + coordinates all fall between 6247133 and 6247134, you're not leaving + much floating-point precision for Triangle to work with. + + Precision problems can occur covertly if the input PSLG contains two + segments that meet (or intersect) at a very small angle, or if such an + angle is introduced by the -c switch, which may occur if a point lies + ever-so-slightly inside the convex hull, and is connected by a PSLG + segment to a point on the convex hull. If you don't realize that a + small angle is being formed, you might never discover why Triangle is + crashing. To check for this possibility, use the -S switch (with an + appropriate limit on the number of Steiner points, found by trial-and- + error) to stop Triangle early, and view the output .poly file with + Show Me (described below). Look carefully for small angles between + segments; zoom in closely, as such segments might look like a single + segment from a distance. + + If some of the input values are too large, Triangle may suffer a + floating exception due to overflow when attempting to perform an + orientation or incircle test. (Read the section on exact arithmetic + above.) Again, I recommend compiling Triangle for double (rather + than single) precision arithmetic. + + `The numbering of the output points doesn't match the input points.' + + You may have eaten some of your input points with a hole, or by placing + them outside the area enclosed by segments. + + `Triangle executes without incident, but when I look at the resulting + mesh, it has overlapping triangles or other geometric inconsistencies.' + + If you select the -X switch, Triangle's divide-and-conquer Delaunay + triangulation algorithm occasionally makes mistakes due to floating- + point roundoff error. Although these errors are rare, don't use the -X + switch. If you still have problems, please report the bug. + + Strange things can happen if you've taken liberties with your PSLG. Do + you have a point lying in the middle of a segment? Triangle sometimes + copes poorly with that sort of thing. Do you want to lay out a collinear + row of evenly spaced, segment-connected points? Have you simply defined + one long segment connecting the leftmost point to the rightmost point, + and a bunch of points lying along it? This method occasionally works, + especially with horizontal and vertical lines, but often it doesn't, and + you'll have to connect each adjacent pair of points with a separate + segment. If you don't like it, tough. + + Furthermore, if you have segments that intersect other than at their + endpoints, try not to let the intersections fall extremely close to PSLG + points or each other. + + If you have problems refining a triangulation not produced by Triangle: + Are you sure the triangulation is geometrically valid? Is it formatted + correctly for Triangle? Are the triangles all listed so the first three + points are their corners in counterclockwise order? + +Show Me: + + Triangle comes with a separate program named `Show Me', whose primary + purpose is to draw meshes on your screen or in PostScript. Its secondary + purpose is to check the validity of your input files, and do so more + thoroughly than Triangle does. Show Me requires that you have the X + Windows system. If you didn't receive Show Me with Triangle, complain to + whomever you obtained Triangle from, then send me mail. + +Triangle on the Web: + + To see an illustrated, updated version of these instructions, check out + + http://www.cs.cmu.edu/~quake/triangle.html + +A Brief Plea: + + If you use Triangle, and especially if you use it to accomplish real + work, I would like very much to hear from you. A short letter or email + (to jrs@cs.cmu.edu) describing how you use Triangle will mean a lot to + me. The more people I know are using this program, the more easily I can + justify spending time on improvements and on the three-dimensional + successor to Triangle, which in turn will benefit you. Also, I can put + you on a list to receive email whenever a new version of Triangle is + available. + + If you use a mesh generated by Triangle in a publication, please include + an acknowledgment as well. + +Research credit: + + Of course, I can take credit for only a fraction of the ideas that made + this mesh generator possible. Triangle owes its existence to the efforts + of many fine computational geometers and other researchers, including + Marshall Bern, L. Paul Chew, Boris Delaunay, Rex A. Dwyer, David + Eppstein, Steven Fortune, Leonidas J. Guibas, Donald E. Knuth, C. L. + Lawson, Der-Tsai Lee, Ernst P. Mucke, Douglas M. Priest, Jim Ruppert, + Isaac Saias, Bruce J. Schachter, Micha Sharir, Jorge Stolfi, Christopher + J. Van Wyk, David F. Watson, and Binhai Zhu. See the comments at the + beginning of the source code for references. +