Files
secondo/Algebras/GPattern/Boids/Vector.cpp

80 lines
2.6 KiB
C++
Raw Permalink Normal View History

2026-01-23 17:03:45 +08:00
/*
----
This file is part of SECONDO.
Copyright (C) 2004, University in Hagen, Department of Computer Science,
Database Systems for New Applications.
SECONDO 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.
SECONDO 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 SECONDO; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
----
This file was originally written by Christopher John Kline, under the copy
right statement below. Mahomud Sakr, September 2011, has made the necessary
changes to make it available as a SECONDO operator.
Copyright (C) 1996, Christopher John Kline
Electronic mail: ckline@acm.org
This software may be freely copied, modified, and redistributed
for academic purposes and by not-for-profit organizations, provided that
this copyright notice is preserved on all copies, and that the source
code is included or notice is given informing the end-user that the source
code is publicly available under the terms described here.
Persons or organizations wishing to use this code or any modified version
of this code in a commercial and/or for-profit manner must contact the
author via electronic mail (preferred) or other method to arrange the terms
of usage. These terms may be as simple as giving the author visible credit
in the final product.
There is no warranty or other guarantee of fitness for this software,
it is provided solely "as is". Bug reports or fixes may be sent
to the author, who may or may not act on them as he desires.
If you use this software the author politely requests that you inform him
via electronic mail.
Vector.c++
CODE: Class for 3-vectors with double precision
(c) 1996 Christopher Kline <ckline@acm.org>
September 2011 Mahmoud Sakr: The Boids simulator/data-generator is now
available as a SECONDO operator.
*/
#include "Vector.h"
using namespace std;
MathVector
Average(int numvectors, MathVector a, ...) {
MathVector v = a;
va_list arg_ptr;
int i;
va_start(arg_ptr, a);
for (i=0; i<numvectors-1; i++)
v += va_arg(arg_ptr, MathVector);
va_end(arg_ptr);
v.x /= numvectors; v.y /= numvectors; v.z /= numvectors;
return(v);
}