added tests for Vector Math, modified Makefile, added helper include files

This commit is contained in:
ejcoumans
2007-08-15 04:54:27 +00:00
parent b43b8f0f75
commit 6b0a3f081c
102 changed files with 91266 additions and 76385 deletions

View File

@@ -1,4 +1,5 @@
# Makefile for testsuite for the PPU SIMD math library
# Makefile for vector math library.
#
# Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
# All rights reserved.
#
@@ -26,103 +27,93 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
TESTS = main_vmtest
# How to build:
#
# Nothing to do (The all of the library is implemented as inline).
#
# How to install:
#
# To install the library:
#
# make ARCH=<ARCHITECTURE> install
#
# where <ARCHITECTURE> must be one of:
#
# ppu (PowerPC)
# spu
# SSE
# scalar (generic)
#
# e.g.) make ARCH=cell install
#
STATIC_TESTS = $(TESTS)
SHARED_TESTS = $(TESTS:=.shared)
ALL_TESTS = $(STATIC_TESTS) $(SHARED_TESTS)
topdir = .
ARCH = scalar
INCLUDES_PPU = -I../simdmathlibrary/common -Iother/rs6000
#ARCH_PPU can also be 64
ARCH_PPU = 32
CROSS_PPU = ppu-
AR_PPU = $(CROSS_PPU)ar
CC_PPU = $(CROSS_PPU)gcc
CXX_PPU = $(CROSS_PPU)g++
TEST_CMD_PPU =
prefix_spu = /usr/spu
ARCH_CFLAGS_PPU = -m$(ARCH_PPU) -maltivec -mabi=altivec
CFLAGS_PPU = $(INCLUDES_PPU) -O2 -W -Wall $(ARCH_CFLAGS_PPU)
STATIC_LDFLAGS_PPU = -static
SHARED_LDFLAGS_PPU = -Wl,-rpath=..
LDFLAGS_PPU = $(ARCH_CFLAGS_PPU) -L../simdmathlibrary/ppu -l$(LIB_BASE) -lm -lstdc++
ARCH_DIRS = $(ARCH)
ARCH_INSTALL= $(ARCH_INSTALL_$(ARCH))
ARCH_CHECK= $(ARCH_CHECK_$(ARCH))
MAKE_DEFS = \
LIB_BASE='$(LIB_BASE)' \
LIB_NAME='$(LIB_NAME)' \
STATIC_LIB='$(STATIC_LIB)' \
SHARED_LIB='$(SHARED_LIB)' \
ARCH_PPU='$(ARCH_PPU)' \
ARCH_CFLAGS_PPU='$(ARCH_CFLAGS_PPU)' \
CROSS_PPU='$(CROSS_PPU)' \
AR_PPU='$(AR_PPU)' \
CC_PPU='$(CC_PPU)' \
CXX_PPU='$(CXX_PPU)' \
TEST_CMD_PPU='$(TEST_CMD_PPU)'
prefix = $(if $(prefix_$(ARCH)),$(prefix_$(ARCH)),/usr)
DESTDIR =
LIB_BASE = simdmath
LIB_NAME = lib$(LIB_BASE)
STATIC_LIB = $(LIB_NAME).a
SHARED_LIB = $(LIB_NAME).so
COMMON_DIRS = scalar
TEST_CMD = $(TEST_CMD_PPU)
INSTALL = install
#COMMON_OBJS = testutils.o
LIB_MAJOR_VERSION = 1
LIB_MINOR_VERSION = 0
LIB_RELEASE = 1
LIB_FULL_VERSION = $(LIB_MAJOR_VERSION).$(LIB_MINOR_VERSION).$(LIB_RELEASE)
LIB_BASE = vectormath
all: $(ALL_TESTS)
TAR_NAME = $(LIB_BASE)-$(LIB_FULL_VERSION)
TAR_BALL = $(TAR_NAME).tar.gz
all:
@true
$(STATIC_TESTS): %: %.o ../simdmathlibrary/ppu/$(STATIC_LIB) $(COMMON_OBJS)
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(STATIC_LDFLAGS_PPU) -o $@
install:
$(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/c
$(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/cpp
$(INSTALL) -m 644 include/vectormath/c/*.h $(DESTDIR)$(prefix)/include/vectormath/c/
$(INSTALL) -m 644 include/vectormath/cpp/*.h $(DESTDIR)$(prefix)/include/vectormath/cpp/
$(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/cpp
for _d in $(ARCH_DIRS) $(COMMON_DIRS); do \
if test -d include/vectormath/$$_d/c; then \
$(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/$$_d/c && \
$(INSTALL) -m 644 include/vectormath/$$_d/c/*.h \
$(DESTDIR)$(prefix)/include/vectormath/$$_d/c/ || exit 1; \
fi; \
if test -d include/vectormath/$$_d/cpp; then \
$(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/$$_d/cpp && \
$(INSTALL) -m 644 include/vectormath/$$_d/cpp/*.h \
$(DESTDIR)$(prefix)/include/vectormath/$$_d/cpp/ || exit 1; \
fi; \
done
$(SHARED_TESTS): %.shared: %.o ../simdmathlibrary/ppu/$(SHARED_LIB) $(COMMON_OBJS)
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(SHARED_LDFLAGS_PPU) -o $@
check:
$(MAKE) -C tests ARCH=$(ARCH) check
clean:
rm -f *.o
rm -f $(STATIC_TESTS) $(SHARED_TESTS)
rm -f core*
$(MAKE) -C tests clean
-rm -f $(TAR_BALL)
check: $(ALL_TESTS)
for test in $(ALL_TESTS); do \
echo "TEST $${test}"; \
if $(TEST_CMD) ./$${test}; then \
pass="$$pass $$test"; \
else \
fail="$$fail $$test"; \
fi \
done; \
echo; echo "PASS:$$pass"; echo "FAIL:$$fail"; \
test -z "$$fail"
static_check:
$(MAKE) $(MAKE_DEFS) ALL_TESTS="$(STATIC_TESTS)" check
shared_check:
$(MAKE) $(MAKE_DEFS) ALL_TESTS="$(SHARED_TESTS)" check
../$(STATIC_LIB):
cd ../;$(MAKE) $(MAKE_DEFS) $(STATIC_LIB)
../$(SHARED_LIB):
cd ../;$(MAKE) $(MAKE_DEFS) $(SHARED_LIB)
%.o: %.c common-test.h testutils.h
$(CC_PPU) $(CFLAGS_PPU) -c $<
#----------
# C++
#----------
%.o: %.C
$(CXX_PPU) $(CFLAGS_PPU) -c $<
%.o: %.cpp
$(CXX_PPU) $(CFLAGS_PPU) -c $<
%.o: %.cc
$(CXX_PPU) $(CFLAGS_PPU) -c $<
%.o: %.cxx
$(CXX_PPU) $(CFLAGS_PPU) -c $<
distclean:
$(MAKE) -C tests distclean
dist:
-rm -rf .dist
mkdir -p .dist/$(TAR_NAME)
find . -name .dist -prune -o \
-name .CVS -prune -o -name .svn -prune -o \
-name .pc -prune -o -name patches -prune -o \
'(' -name README -o -name LICENSE -o \
-name Makefile -o -name '*.[ch]' -o -name '*.cpp' -o \
-name '*.pl' -o -name '*.txt' -o -name '*.pdf' -o -name '*.spec' ')' \
-print | tar -T - -cf - | tar xf - -C .dist/$(TAR_NAME)
tar zcf $(TAR_BALL) -C .dist $(TAR_NAME)
-rm -rf .dist

View File

@@ -1,86 +1,13 @@
Vector math library
Vector Math library for 3-D linear algebra (vector, matrix, quaternion)
SIMD support for SSE, PowerPC (PPU) and the SPU.
Also includes generic multi-platform scalar version.
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
Open Source under the new BSD license, see LICENSE
* Overview
Module maintainer: Erwin Coumans
Feedback and patches:
http://www.bulletphysics.com/Bullet/phpBB2/viewforum.php?f=18
Main repository URL:
http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/vectormathlibrary
The Vector math library provides 3-D/4-D vector operations including
addition, outer product, multiply by a matrix, etc.
* License
This library is licensed under the terms in the file 'LICENSE' in
this directory.
* Installing
To install this library, run following commands:
- PowerPC with VMX (fully supported)
$ make ARCH=ppu install
- SPU (Cell Broadband Engine Synergistic Processor Unit)
$ make ARCH=spu install
- x86 with SSE (partially supported)
$ make ARCH=SSE install
- Other architectures (partially supported)
$ make install
By default, files in the library will be placed as below:
- headers
/usr/include/vectormath/c/ (C headers)
/usr/include/vectormath/cpp/ (C++ headers)
- SPU headers
/usr/spu/include/vectormath/c/ (C headers)
/usr/spu/include/vectormath/cpp/ (C++ headers)
No shared library, static library nor executable is installed,
because all functions in this library are provided as inline
functions.
* Packaging
By running following command in this directory, a source tarball
'vectormath-<VERSION>.tar.gz' can be created:
$ make dist
You can also create RPM packages by executing the command below with
the tarball:
$ rpmbuild -tb vectormath-1.0.1.tar.gz --target=ppc
One or two packages, vectormath-devel (and, in addition,
spu-vectormath-devel for PowerPC target), will be created.
* Usage
See the documents `doc/*.pdf'.
* Contacting the project
Module maintainer: Erwin Coumans
Feedback and patches:
http://www.bulletphysics.com/Bullet/phpBB2/viewforum.php?f=18
Main repository URL:
http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/vectormathlibrary
---
EOF

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_CPP_H
#define _VECTORMATH_AOS_CPP_H
#ifndef _VECTORMATH_AOS_CPP_SSE_H
#define _VECTORMATH_AOS_CPP_SSE_H
#include <math.h>
#include <xmmintrin.h>

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_H
#define _VECTORMATH_AOS_C_H
#if defined(__SPU__)
# include "../spu/c/vectormath_aos.h"
#elif defined(__ALTIVEC__)
# include "../ppu/c/vectormath_aos.h"
#else
# include "../scalar/c/vectormath_aos.h"
#endif
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_V_H
#define _VECTORMATH_AOS_C_V_H
#if defined(__SPU__)
# include "../spu/c/vectormath_aos_v.h"
#elif defined(__ALTIVEC__)
# include "../ppu/c/vectormath_aos_v.h"
#else
# include "../scalar/c/vectormath_aos_v.h"
#endif
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_H
#define _VECTORMATH_SOA_C_H
#if defined(__SPU__)
# include "../spu/c/vectormath_soa.h"
#elif defined(__ALTIVEC__)
# include "../ppu/c/vectormath_soa.h"
#else
# error "Not implemented."
#endif
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_V_H
#define _VECTORMATH_SOA_C_V_H
#if defined(__SPU__)
# include "../spu/c/vectormath_soa_v.h"
#elif defined(__ALTIVEC__)
# include "../ppu/c/vectormath_soa_v.h"
#else
# error "Not implemented."
#endif
#endif

View File

@@ -0,0 +1,43 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_CPP_H
#define _VECTORMATH_AOS_CPP_H
#if defined(__SPU__)
# include "../spu/cpp/vectormath_aos.h"
#elif defined(__ALTIVEC__)
# include "../ppu/cpp/vectormath_aos.h"
#elif defined(__SSE__)
# include "../SSE/cpp/vectormath_aos.h"
#else
# include "../scalar/cpp/vectormath_aos.h"
#endif
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_CPP_H
#define _VECTORMATH_SOA_CPP_H
#if defined(__SPU__)
# include "../spu/cpp/vectormath_soa.h"
#elif defined(__ALTIVEC__)
# include "../ppu/cpp/vectormath_soa.h"
#else
# error "Not implemented."
#endif
#endif

View File

@@ -30,8 +30,9 @@
#ifndef _VECTORMATH_VEC_AOS_C_H
#define _VECTORMATH_VEC_AOS_C_H
#include <altivec.h>
#include <vec_types.h>
#include <simdmath.h>
#include <stddef.h>
#include "vec_types.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

View File

@@ -0,0 +1,55 @@
/* (C) Copyright
Sony Computer Entertainment, Inc.,
2001,2002,2003,2004,2005,2006,2007.
This file 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 file 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 file; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* As a special exception, if you include this header file into source files
compiled by GCC, this header file does not by itself cause the resulting
executable to be covered by the GNU General Public License. This exception
does not however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
/* Single token vector data types for the PowerPC SIMD/Vector Multi-media
eXtension */
#ifndef _VECTORMATH_VEC_TYPES_H_
#define _VECTORMATH_VEC_TYPES_H_ 1
#define qword __vector unsigned char
#define vec_uchar16 __vector unsigned char
#define vec_char16 __vector signed char
#define vec_bchar16 __vector bool char
#define vec_ushort8 __vector unsigned short
#define vec_short8 __vector signed short
#define vec_bshort8 __vector bool short
#define vec_pixel8 __vector pixel
#define vec_uint4 __vector unsigned int
#define vec_int4 __vector signed int
#define vec_bint4 __vector bool int
#define vec_float4 __vector float
#define vec_ullong2 __vector bool char
#define vec_llong2 __vector bool short
#define vec_double2 __vector bool int
#endif /* _VECTORMATH_VEC_TYPES_H_ */

View File

@@ -27,13 +27,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_H
#define _VECTORMATH_AOS_C_H
#ifndef _VECTORMATH_AOS_C_PPU_H
#define _VECTORMATH_AOS_C_PPU_H
#include <math.h>
#include <altivec.h>
#include <vec_types.h>
#include <simdmath.h>
#include "vec_types.h"
#ifdef _VECTORMATH_DEBUG
#include <stdio.h>

View File

@@ -27,11 +27,12 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_V_H
#define _VECTORMATH_AOS_C_V_H
#ifndef _VECTORMATH_AOS_C_V_PPU_H
#define _VECTORMATH_AOS_C_V_PPU_H
#include <math.h>
#include <altivec.h>
#include "vec_types.h"
#ifdef _VECTORMATH_DEBUG
#include <stdio.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_H
#define _VECTORMATH_SOA_C_H
#ifndef _VECTORMATH_SOA_C_PPU_H
#define _VECTORMATH_SOA_C_PPU_H
#include <math.h>
#include <altivec.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_V_H
#define _VECTORMATH_SOA_C_V_H
#ifndef _VECTORMATH_SOA_C_V_PPU_H
#define _VECTORMATH_SOA_C_V_PPU_H
#include <math.h>
#include <altivec.h>

View File

@@ -32,7 +32,7 @@
#include <math.h>
#include <altivec.h>
#include "vec_types.h"
#include "../c/vec_types.h"
#undef bool
namespace Vectormath {

View File

@@ -33,8 +33,8 @@
#include <math.h>
#include <altivec.h>
#include <stddef.h>
#include "vec_types.h"
#include "simdmath.h"
#include <simdmath.h>
#include "../c/vec_types.h"
#undef bool
namespace Vectormath {

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_CPP_H
#define _VECTORMATH_AOS_CPP_H
#ifndef _VECTORMATH_AOS_CPP_PPU_H
#define _VECTORMATH_AOS_CPP_PPU_H
#include <math.h>
#include <altivec.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_CPP_H
#define _VECTORMATH_SOA_CPP_H
#ifndef _VECTORMATH_SOA_CPP_PPU_H
#define _VECTORMATH_SOA_CPP_PPU_H
#include <math.h>
#include <altivec.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_H
#define _VECTORMATH_AOS_C_H
#ifndef _VECTORMATH_AOS_C_SCALAR_H
#define _VECTORMATH_AOS_C_SCALAR_H
#include <math.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_V_H
#define _VECTORMATH_AOS_C_V_H
#ifndef _VECTORMATH_AOS_C_V_SCALAR_H
#define _VECTORMATH_AOS_C_V_SCALAR_H
#include <math.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_CPP_H
#define _VECTORMATH_AOS_CPP_H
#ifndef _VECTORMATH_AOS_CPP_SCALAR_H
#define _VECTORMATH_AOS_CPP_SCALAR_H
#include <math.h>

View File

@@ -27,13 +27,12 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_H
#define _VECTORMATH_AOS_C_H
#ifndef _VECTORMATH_AOS_C_SPU_H
#define _VECTORMATH_AOS_C_SPU_H
#include <math.h>
#include "spu2vmx.h"
#include "simdmath.h"
#include "stdio.h"
#include <simdmath.h>
#include <stdio.h>
#ifdef _VECTORMATH_DEBUG
#endif

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_C_V_H
#define _VECTORMATH_AOS_C_V_H
#ifndef _VECTORMATH_AOS_C_V_SPU_H
#define _VECTORMATH_AOS_C_V_SPU_H
#include <math.h>
#include <spu_intrinsics.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_H
#define _VECTORMATH_SOA_C_H
#ifndef _VECTORMATH_SOA_C_SPU_H
#define _VECTORMATH_SOA_C_SPU_H
#include <math.h>
#include <spu_intrinsics.h>

View File

@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_C_V_H
#define _VECTORMATH_SOA_C_V_H
#ifndef _VECTORMATH_SOA_C_V_SPU_H
#define _VECTORMATH_SOA_C_V_SPU_H
#include <math.h>
#include <spu_intrinsics.h>

View File

@@ -32,8 +32,7 @@
#include <math.h>
#include <spu_intrinsics.h>
#include "spu2vmx.h"
#include "simdmath.h"
#include <simdmath.h>
#undef bool
namespace Vectormath {

View File

@@ -27,15 +27,15 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_AOS_CPP_H
#define _VECTORMATH_AOS_CPP_H
#ifndef _VECTORMATH_AOS_CPP_SPU_H
#define _VECTORMATH_AOS_CPP_SPU_H
#include <math.h>
#include <spu_intrinsics.h>
#include "floatInVec.h"
#include "boolInVec.h"
#include "stdio.h"
#include "vecidx_aos.h"
#include <stdio.h>
#ifdef _VECTORMATH_DEBUG
#endif

View File

@@ -27,15 +27,15 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_SOA_CPP_H
#define _VECTORMATH_SOA_CPP_H
#ifndef _VECTORMATH_SOA_CPP_SPU_H
#define _VECTORMATH_SOA_CPP_SPU_H
#include <math.h>
#include <spu_intrinsics.h>
#include "floatInVec.h"
#include "boolInVec.h"
#include "stdio.h"
#include "vectormath_aos.h"
#include <stdio.h>
#ifdef _VECTORMATH_DEBUG
#endif

View File

@@ -0,0 +1,135 @@
# Makefile for vector math library testsuite.
#
# Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the
# following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Sony Computer Entertainment Inc nor the names
# of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
topdir = ..
ARCH = scalar
TESTS_all = \
test1_aos_c.elf \
test1_soa_c.elf \
test2_aos_c.elf \
test2_soa_c.elf \
test3_aos_c.elf \
test3_soa_c.elf \
test4_aos_c.elf \
test4_soa_c.elf \
test1_aos_cpp.elf \
test1_soa_cpp.elf \
test2_aos_cpp.elf \
test2_soa_cpp.elf \
test3_aos_cpp.elf \
test3_soa_cpp.elf \
test4_aos_cpp.elf \
test4_soa_cpp.elf
TESTS_ppu = $(TESTS_all)
ARCH_CFLAGS_ppu = -maltivec -mabi=altivec -I$(SIMDMATH_DIR)/common
ARCH_LDFLAGS_ppu = -L$(SIMDMATH_DIR)/ppu -lsimdmath -static
TESTS_spu = $(TESTS_all)
ARCH_CFLAGS_spu = -I$(SIMDMATH_DIR)/common
ARCH_LDFLAGS_spu = -L$(SIMDMATH_DIR)/spu -lsimdmath
TESTS_SSE = \
test1_aos_cpp.elf \
test2_aos_cpp.elf \
test3_aos_cpp.elf \
test4_aos_cpp.elf
ARCH_CFLAGS_SSE = -msse
TESTS_scalar = \
test1_aos_c.elf \
test2_aos_c.elf \
test3_aos_c.elf \
test4_aos_c.elf \
test1_aos_cpp.elf \
test2_aos_cpp.elf \
test3_aos_cpp.elf \
test4_aos_cpp.elf
TESTS = $(TESTS_$(ARCH))
ARCH_CFLAGS = $(ARCH_CFLAGS_$(ARCH))
ARCH_LDFLAGS = $(ARCH_LDFLAGS_$(ARCH))
SIMDMATH_DIR = $(topdir)/../simdmathlibrary
RESULTS = $(TESTS:.elf=.$(ARCH).out)
DIFFS = $(RESULTS:.out=.cmp)
CROSS =
CC = $(CROSS)gcc
CXX = $(CROSS)g++
LD = $(CC)
LDXX = $(CXX)
CFLAGS = -O2 -W -Wall -D_VECTORMATH_DEBUG $(ARCH_CFLAGS)
LDFLAGS = -lm $(ARCH_LDFLAGS)
C_INCLUDES = -I$(topdir)/include/vectormath/c
CXX_INCLUDES = -I$(topdir)/include/vectormath/cpp
all: $(TESTS)
check: $(DIFFS)
clean:
-rm -f *.elf
distclean: clean
-rm -f *.out *.cmp *~
%_c.elf: %_c.c
$(CC) $(CFLAGS) $(C_INCLUDES) -o $@ $< $(LDFLAGS)
%_cpp.elf: %_cpp.cpp
$(CXX) $(CFLAGS) $(CXX_INCLUDES) -o $@ $< $(LDFLAGS)
%.$(ARCH).out: %.elf
./$< > $@
test1_%.cmp: test1_%.out
./clean.pl < $< > $<.tmp
./compare.pl $<.tmp test1_reference.txt | tee $@
rm $<.tmp
test2_%.cmp: test2_%.out
./clean.pl < $< > $<.tmp
./compare.pl $<.tmp test2_reference.txt | tee $@
rm $<.tmp
test3_%.cmp: test3_%.out
./clean.pl < $< > $<.tmp
./compare.pl $<.tmp test3_reference.txt | tee $@
rm $<.tmp
test4_%.cmp: test4_%.out
./clean.pl < $< > $<.tmp
./compare.pl $<.tmp test4_reference.txt | tee $@
rm $<.tmp

View File

@@ -0,0 +1,109 @@
#!/usr/bin/perl
#
# Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the
# following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Sony Computer Entertainment Inc nor the names
# of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
$lineno = 0;
sub getLine
{
local( $line );
$line = <STDIN>;
while( $line =~ m/^lv2\([^\)]*\)\:$/ )
{
$line = <STDIN>;
}
$line =~ s/^lv2\([^\)]*\)\: //;
return $line;
}
while(($line = <STDIN>) !~ m/__begin__/)
{
}
$countSlotLines = 0;
while( $line = &getLine )
{
$lineno++;
if ( $line =~ m/__end__/ )
{
exit;
}
# if soa print, only save first slot
if ( $line =~ m/^slot ([1-3])/ )
{
while ( $line =~ m/^slot [1-3]/ )
{
# skip all lines for this slot
for ( $i = 0; $i < $slotLines; $i++ )
{
$line = &getLine;
}
# get next line
$line = &getLine;
}
# stop counting slot lines
$countSlotLines = 0;
}
elsif ( $countSlotLines )
{
$slotLines++;
}
if ( $line =~ m/^slot 0\:(.?)/ )
{
$countSlotLines = 1;
if ( $1 eq ' ' )
{
$line =~ s/^slot 0\: //;
$slotLines = 0;
}
else
{
$line = &getLine;
$slotLines = 1;
}
}
print $line;
}

View File

@@ -0,0 +1,95 @@
#!/usr/bin/perl
#
# Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the
# following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Sony Computer Entertainment Inc nor the names
# of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
$file1 = $ARGV[0];
$file2 = $ARGV[1];
if (!open(FILE1, "<$file1"))
{
print "Couldn't open $file1\n";
exit;
}
if (!open(FILE2, "<$file2"))
{
print "Couldn't open $file2\n";
exit;
}
print "Comparing $file1 $file2\n";
$lineno1 = 0;
$lineno2 = 0;
while(($line1 = <FILE1>) && ($line2 = <FILE2>))
{
$lineno1++;
$lineno2++;
if ( $line1 =~ m/\:$/ )
{
$line1 = <FILE1>;
$lineno1++;
}
if ( $line2 =~ m/\:$/ )
{
$line2 = <FILE2>;
$lineno2++;
}
$line1 =~ s/^.*\: //g;
$line2 =~ s/^.*\: //g;
@words1 = split(/ /,$line1);
@words2 = split(/ /,$line2);
for ($i = 0; $i < @words1; $i++)
{
$word1 = $words1[$i];
$word2 = $words2[$i];
$word1 =~ s/\s//g;
$word2 =~ s/\s//g;
if ( $word1 ne $word2 )
{
$error = abs($word1 - $word2);
$limit = abs(1e-4 * $word1);
if ( $error > $limit && !( abs($word1) < 1e-4 && $error < 1e-4 ) )
{
print "$lineno1: $word1 $lineno2: $word2\n";
}
}
}
}

View File

@@ -0,0 +1,346 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_TEST_H
#define _VECTORMATH_TEST_H
#if defined(__SPU__)
# define vec_splats_float(v) spu_splats(v)
# define vec_mul_float(a, b) spu_mul(a, b)
# define vec_add_float(a, b) spu_add(a, b)
# define vec_sub_float(a, b) spu_sub(a, b)
#elif defined(__ALTIVEC__)
# define vec_splats_float(v) ((vec_float4){(float)(v),(float)(v),(float)(v),(float)(v)})
# define vec_mul_float(a, b) vec_madd(a, b, vec_splats_float(0.0f))
# define vec_add_float(a, b) vec_add(a, b)
# define vec_sub_float(a, b) vec_sub(a, b)
#elif defined(__SSE__)
# error "Not implemented."
#else
# define _VECTORMATH_SCALAR_TEST
#endif
float randfloats[1024] = {
-0.658343927787421f,0.499803960969928f,-0.807256688752865f,0.740930454054151f,
0.154607013590216f,0.571598517679348f,0.38438830691728f,-0.262467460159158f,
0.747808153723618f,0.49019019690013f,-0.107908181813777f,-0.292543593813249f,
0.465039264005078f,-0.47955599783424f,-0.211412450152245f,0.553579902451233f,
0.690070275160572f,0.151576400965553f,0.431077190337326f,-0.833991507852247f,
-0.0883497426804851f,-0.780106371638709f,0.0904560476331469f,-0.218626858702649f,
0.137170846428894f,0.918132898976751f,0.735438192918274f,-0.673620979495283f,
-0.448982146263369f,-0.479277810255866f,0.848189483738331f,-0.12815472579463f,
0.578921731104181f,-0.744765966376519f,-0.83558862791913f,0.881284032895692f,
-0.948850147493964f,-0.691578137344351f,-0.235635149443688f,-0.690526600666615f,
0.0586668362339609f,0.753696982166502f,-0.138777123323202f,-0.472187547315841f,
-0.372811001953572f,0.540183371709446f,-0.78521823389179f,0.542084510391291f,
0.410391117788897f,-0.562720682584484f,0.523587985711991f,-0.176573908842087f,
0.297653645858226f,0.859912509814734f,0.00483713119734119f,0.374881358857735f,
-0.127818103705344f,0.21660181589948f,0.153117267270737f,0.265243421428139f,
-0.0731487047425148f,0.264487579220173f,-0.723410134701346f,0.921522835850382f,
-0.711249997824318f,-0.106633857864438f,-0.350831080309241f,0.905168155184938f,
-0.283632179037646f,-0.203583555015513f,-0.797436915535236f,0.910171471305759f,
0.96923389534215f,0.151940162902974f,0.731827470770519f,-0.700248217534451f,
0.818300860563319f,0.302505017280083f,-0.872278290470156f,0.909998773124912f,
0.932525528551317f,0.571086770427939f,0.610329635790002f,0.142507359591505f,
-0.43482856009151f,0.925102103935927f,0.158954117892613f,-0.126282746058862f,
-0.249127650925452f,0.846815218386041f,-0.942601239873774f,0.537719955431001f,
0.446213543435171f,0.181938699625931f,-0.148222922840326f,0.284286118166037f,
0.493525458201255f,-0.861962900371793f,-0.893410102755276f,0.548627291142694f,
0.407006961478977f,-0.757467096890906f,-0.393126176069536f,-0.850984293029867f,
0.375719573110992f,-0.270087780463427f,0.45888819784826f,-0.610827766442796f,
-0.690815628408266f,-0.676415221072347f,0.664465776005038f,0.101873923854313f,
-0.365713939355025f,0.0554727439164822f,-0.133556089035984f,-0.572643072647438f,
0.459209235899415f,-0.997261395030506f,0.172408991295974f,-0.0451240115316551f,
0.879715937508259f,0.524317125330867f,-0.744532077249495f,-0.970443523820151f,
-1.32784686215359e-05f,0.689543072301063f,0.704297111725616f,-0.817983008667298f,
0.71550535643383f,0.577868436783262f,0.156952383805468f,-0.80102179210472f,
0.65633547615213f,0.494393128677046f,0.816743155389922f,0.0242848471199721f,
0.769131722839866f,0.923894866655701f,0.133021600755988f,-0.0522193159450097f,
-0.164886284373118f,0.300690282133047f,0.760403145270168f,0.171869369152077f,
-0.554975788488598f,0.998693253807744f,-0.681641007087912f,0.391194738828759f,
0.403058705852153f,0.972411306067528f,0.297195187773745f,0.309761312769567f,
0.688408077837671f,0.363539666742895f,0.94029653976505f,-0.336683042511069f,
0.600164345782652f,-0.681271587780742f,0.726558239385319f,0.205513360229233f,
-0.16008221686365f,0.962714155748642f,0.737793770111715f,-0.0719258703692134f,
-0.506312816314299f,0.689277082946518f,0.686485424709581f,0.473013144786293f,
-0.735610421404026f,-0.0463900680836105f,0.568673968586005f,-0.00481466271939723f,
0.137636823654454f,-0.111879120785687f,-0.929542605813147f,-0.336303463382606f,
-0.146740182632236f,0.165140351947514f,-0.823874099621072f,0.349776463047661f,
0.174872304411146f,-0.528584334304156f,0.489291834762803f,0.916707538240686f,
0.728510889338118f,-0.851139787348188f,0.0796199799283031f,-0.234369971523549f,
-0.996308342568362f,0.433228819394486f,-0.892684128206504f,-0.95791073791078f,
0.517122298113016f,0.257920984044574f,0.862028434359466f,0.0958813977553206f,
-0.171932523577503f,-0.214077886807473f,-0.604841274532937f,-0.38383141210609f,
-0.58149997525441f,0.222182734948547f,-0.2561203625418f,-0.678699493062183f,
-0.0795530448181339f,0.605960090732907f,-0.633147389976791f,0.435875222532317f,
-0.0466270522618899f,-0.71649136999298f,0.267317414957141f,-0.514873596167021f,
-0.751699524124625f,0.742958874040227f,-0.793179510948171f,0.508814009999512f,
-0.238839286150373f,0.113471002014307f,-0.843523253083085f,-0.245249991279181f,
0.250368454758338f,0.579243470287253f,-0.157280074848025f,0.648487464157242f,
0.103833079240538f,0.456401128469849f,-0.0223720820167514f,-0.475631368950744f,
-0.0041782226245104f,-0.0208652308868125f,-0.0169971127675765f,0.699143621917685f,
0.83779636548531f,-0.276082033737794f,0.0915817913013015f,0.209063902268738f,
0.219316780269516f,-0.118359453100055f,0.413442003735092f,-0.567697560481989f,
0.531358299984625f,-0.387225776610819f,0.572489506868486f,-0.820417090039186f,
0.797191361229615f,0.867177919412683f,0.934764375062564f,0.237092079542023f,
-0.866161864691826f,-0.773938728379676f,0.261310530107004f,-0.851569556583101f,
0.114814425111355f,-0.531592190789155f,0.223924683490957f,0.869104561345111f,
0.143404566999386f,0.148517529008075f,-0.0711363985626363f,-0.758291614176514f,
-0.527633502740933f,0.99721511923596f,0.114439963849399f,0.72755837253878f,
-0.425760405626697f,0.459888066153781f,0.642515762634126f,-0.0225335867899474f,
0.186094961562027f,-0.775678571017551f,-0.683400976752644f,0.398133764191002f,
0.189642093838877f,0.765986315134853f,-0.137794739254879f,-0.579843714684088f,
-0.63564699482432f,0.374970154657689f,-0.563749876868947f,-0.471075422601373f,
-0.553799500723066f,-0.0146881150006948f,-0.464365244644604f,-0.10788986146774f,
-0.527503023060852f,-0.406422760262416f,0.301261161950258f,0.499528573888128f,
0.385179609005043f,-0.150218387266079f,0.519111879977139f,-0.203208683924331f,
-0.252017508479717f,0.282193567323901f,0.0676372217166588f,0.798376368300907f,
0.310782163860559f,0.861334103612307f,-0.980345166653173f,-0.655105604450725f,
0.286765236319503f,0.532078410709602f,0.352670966735097f,0.540977184819425f,
0.510961465933072f,0.791871139829084f,-0.564378698589145f,0.273199199047909f,
0.194378063163676f,0.244636363558442f,-0.2696079922111f,-0.858162214209599f,
-0.495023067522474f,-0.277797538673553f,-0.0327403642191157f,0.00741169596342672f,
-0.420178428178723f,-0.522576683894926f,0.324971970060567f,0.795389045001329f,
0.342900104539247f,-0.913636452280628f,0.675221839440177f,0.144052833646484f,
-0.632328982629893f,-0.947119831218089f,-0.0493673719309484f,0.126332763266575f,
-0.66420574517786f,0.220879155225703f,0.284218535482147f,-0.387215543918998f,
0.913567998448777f,0.531906099678991f,0.271995095904906f,-0.862600551020719f,
-0.738693635668703f,0.514248487507359f,-0.0393632803376036f,0.429389595727585f,
-0.769468991576751f,0.28133632724311f,-0.203301313955485f,0.412585911285348f,
0.567925862321268f,0.410131004328946f,-0.462918277454527f,0.560952548692129f,
-0.731715443500342f,-0.446157565377547f,-0.837491324975311f,-0.573480361464263f,
-0.607819850918752f,0.23841499693998f,0.213445432027605f,0.0986122683758737f,
0.135072190814675f,-0.749273552937012f,-0.855977160741141f,0.765675059673342f,
-0.693447453911567f,0.131554184087008f,-0.366756547983336f,-0.330409262236842f,
-0.588815619465343f,0.352532978762866f,-0.920522750723883f,-0.915255088789323f,
0.631923943060777f,-0.870739292438145f,0.415604498050605f,-0.180973894496887f,
0.775697838994837f,0.879356890591083f,-0.993957564335638f,-0.298451942545356f,
0.876855036440425f,0.982846031192253f,-0.282564044364371f,0.95346849594155f,
-0.947311505090191f,-0.317822974923359f,0.692391664998802f,-0.123566763365389f,
0.407041678839057f,0.141204372181107f,-0.793069847914673f,-0.638275471740698f,
-0.51955405631346f,0.368499710074474f,0.970213689037045f,0.0272163305900648f,
0.801791483976395f,-0.0663635812993562f,-0.0512834823579524f,-0.184935295126749f,
0.516982835871183f,-0.769951152485618f,-0.708267044537941f,0.398266880674086f,
-0.479614543356881f,0.0604142126476859f,-0.867394563338259f,-0.702364045743693f,
-0.18260171523908f,-0.83280747136078f,0.278190893454216f,-0.967562302471109f,
-0.52029595778054f,0.160191201466318f,-0.677989785356466f,-0.470750261667419f,
-0.846579999787899f,-0.705750757861409f,-0.825367487626302f,-0.712890462610304f,
-0.0644873847193068f,0.444064587944183f,-0.0452257881147275f,0.116544259603998f,
-0.00728451932408092f,-0.838230133415692f,-0.410766823165496f,-0.40929905742685f,
-0.336682948179195f,-0.830699768111344f,-0.801729180453698f,-0.595152571835385f,
-0.784671779507129f,-0.653655236426147f,0.670791046451306f,0.653571468806589f,
0.850715654625567f,0.0714334825891569f,-0.0577154211012854f,0.401895373758876f,
0.0168605144772656f,0.5354384129881f,0.965901293540405f,-0.0726753529456374f,
0.341689326326282f,0.781662445971847f,0.707322369548329f,0.505889413040066f,
0.43279006682301f,-0.82579284323046f,0.597718837056043f,-0.250904847502525f,
-0.085712490334565f,-0.27284668464705f,0.552644217406645f,0.19420250718521f,
-0.884426763638054f,-0.756791257372726f,0.121106956043313f,0.312482778322803f,
-0.873316960494485f,0.0450805196969668f,0.687443898195021f,-0.684625629977333f,
-0.994046624794031f,0.800365484075002f,-0.565640229111075f,-0.625626063021869f,
0.932584676112249f,0.636927568286012f,0.420250137262336f,0.175862511828669f,
0.362158342804186f,0.547495978208275f,-0.534422794348934f,-0.563030463450744f,
-0.254488285756501f,0.647777595706543f,-0.674240168502628f,0.224344628949055f,
-0.754563097553635f,-0.12881655237274f,-0.997838330250381f,0.0369162049154141f,
-0.077549312424928f,0.376025736059717f,-0.935044655882827f,-0.189804125597547f,
0.00764933224392195f,-0.440298102088747f,0.994796322297979f,-0.271484040660724f,
-0.2590701870053f,0.902148580301628f,-0.836501451887365f,0.229092669621153f,
0.5863932076197f,-0.287825592948792f,0.942655407357726f,-0.634432455852235f,
-0.140437555704573f,0.570869095619685f,-0.764965080867434f,0.0675228424859284f,
-0.514589062662218f,0.233090988246516f,0.554487773397391f,-0.633529215840056f,
-0.0193735702003366f,0.869258510751365f,-0.369818396412519f,-0.280689998188947f,
-0.797208739895403f,-0.255233407527697f,0.780605315236578f,0.789803426518219f,
0.974261893445153f,-0.785980203848396f,-0.701385987245636f,0.871088183435759f,
0.566742533772562f,0.75227294222347f,-0.476301298243307f,-0.747341931420877f,
0.0773855838641069f,-0.305599507084935f,-0.229193881336336f,-0.260009071921601f,
-0.0515187258224827f,0.459831012841761f,0.861793377659517f,-0.00839510548009059f,
-0.0535644390132504f,0.912885769359548f,-0.402379747450233f,-0.10435292389046f,
0.644045025641198f,-0.235395897167933f,0.454549452554879f,-0.303775931682779f,
0.321575614700528f,0.724025709176772f,0.330082831646187f,0.609903689400269f,
0.851604270169993f,-0.356715440425745f,-0.0455002843413084f,0.13772975575408f,
-0.148995564903764f,0.892453960056798f,-0.821676934893254f,-0.14847536459807f,
-0.381886292618752f,0.398820351836747f,-0.292289360617424f,0.0702858731114446f,
-0.772469821167697f,0.474357996692333f,0.857792314833965f,-0.720558506386439f,
0.888908862188352f,-0.950919194501893f,-0.196258139903655f,-0.59980821479941f,
-0.794413298851502f,-0.927635622930836f,-0.18747758800405f,-0.113038430406718f,
0.366119602275866f,-0.483786056117111f,0.622670249344587f,-0.801805699607442f,
0.295383348060291f,0.0220054959489744f,-0.000678144987013241f,-0.68933407333013f,
0.266537772395942f,-0.785099000882013f,-0.572664686201399f,0.772760435300924f,
0.97189582826514f,-0.961362535549199f,0.723449439795125f,-0.758441529489218f,
-0.733158222482722f,0.13966678591575f,-0.73814671277507f,0.727223546774141f,
0.0899213092919311f,-0.113118130362636f,-0.364554501988017f,-0.137644753297124f,
0.933846571857863f,0.615857754190102f,0.442837902751755f,0.691293553853697f,
0.862436507424839f,-0.769632706987466f,-0.069558455823973f,-0.216368763497925f,
-0.240286864167238f,-0.494147338088084f,-0.732343541285623f,0.247500097354347f,
0.238013165932848f,-0.0222504081638135f,0.0354097573205863f,0.562870060908224f,
-0.443182852051812f,-0.148476065390099f,-0.785559583638936f,-0.534284390277335f,
0.804060941136193f,0.161693072162677f,0.626454348053834f,0.564290128221401f,
0.414242183673117f,-0.314079097076757f,0.871460392700492f,-0.586016607169839f,
0.446183340840953f,0.670697807509214f,-0.31261251323f,-0.34635111476409f,
-0.32237160168031f,0.0615992346122596f,0.108866036772035f,-0.96854607364277f,
-0.0900520153269255f,-0.000638517939648864f,-0.497526906200939f,0.0210549572282304f,
-0.513626724036349f,0.219974002433304f,-0.406318097379831f,0.829310754424156f,
0.139888080843043f,-0.409132737685127f,-0.0296375827238435f,-0.713853913104842f,
0.286946651436075f,-0.734473045715816f,0.649341057254212f,0.0281454231254514f,
-0.188432361127518f,-0.683807673918693f,0.432885949511977f,-0.0361810926016091f,
0.438347837417645f,0.710651677026334f,0.673928786874676f,-0.0546809333762468f,
0.826058562813905f,-0.832265197271681f,-0.668493142354613f,0.35502470967181f,
0.5354983136667f,0.82137347039f,-0.143300610352533f,0.713426364459551f,
-0.297806605505109f,0.340760003596245f,-0.564118270640485f,-0.0240265108522948f,
-0.60137093958766f,-0.178866127631323f,-0.229680331692812f,0.741055717732976f,
-0.219526898682084f,0.534269946476002f,0.133115059442581f,-0.249583317941799f,
0.811487242943805f,0.699282902509054f,-0.43331663912921f,0.71961761681392f,
0.943524928147106f,0.523603303061634f,-0.677065472025312f,-0.636492873531878f,
0.0384525794274069f,-0.377124785497273f,0.967031372742831f,0.435091298236713f,
0.161520957813146f,-0.15972397671726f,-0.166845254078147f,-0.587937091804449f,
0.910419348982238f,0.764819474485904f,-0.987496701506423f,-0.838882086564368f,
-0.41301635023239f,0.740276015423035f,0.951437768918503f,0.284889876776347f,
-0.158434377954073f,0.73838340645338f,-0.370863653408783f,0.989946556977472f,
-0.848079748582045f,-0.449771614068709f,0.663499305019705f,-0.93185425837116f,
0.523896920061681f,-0.232489928806984f,-0.538281594630583f,-0.899682373052556f,
-0.338756398325579f,0.951550867830917f,0.494550167204373f,0.194556783574981f,
0.243717136517866f,0.224354070146973f,0.143792613511486f,-0.333553884855363f,
0.229952471240104f,-0.204077808365582f,0.469903146410694f,-0.958373658125808f,
-0.226054823628623f,0.229899490605959f,0.196501423332386f,0.879845549743308f,
0.577560209175438f,0.641089277668982f,0.642316105885037f,0.232802361926147f,
-0.381538604113949f,0.640474533642731f,-0.913151229860155f,-0.614188561923768f,
0.171776090268345f,-0.645757746280538f,-0.122217277374411f,0.00689941379876302f,
0.019433549917359f,-0.0675691088088968f,-0.373650414044171f,-0.67103881780362f,
0.504459382741295f,-0.14911057310502f,0.148122926701966f,0.694898716737626f,
0.585837578674649f,-0.750790936323284f,0.853926520879604f,0.15730556487317f,
-0.113618219173468f,0.320367463625416f,-0.552134285767956f,-0.920422170186882f,
-0.338845809007829f,-0.810536065394189f,-0.177695639626343f,0.351905028679525f,
0.0633494717407146f,-0.865174843305965f,0.634557634797282f,-0.787750206138512f,
-0.379512173859858f,0.791878043518267f,-0.704956748246282f,-0.670757904173982f,
0.684751731590218f,-0.953277716787511f,0.985770879077755f,0.122219634876117f,
0.1721202012071f,-0.388256876288864f,-0.73825752183587f,0.906019401398325f,
-0.803381430261645f,-0.74941181755554f,0.0727255174881734f,-0.221605735994771f,
-0.564223723915198f,-0.213656403861052f,-0.608162856680174f,0.921170937654253f,
0.0847855661657562f,0.417987807384179f,-0.330418934403873f,0.648809934312297f,
0.0796460930869003f,0.550628835897015f,-0.92719924470385f,0.877452232036589f,
0.559779671355166f,-0.0896538710039181f,0.849093177103803f,-0.747330460544603f,
-0.87952842676733f,0.791614152693995f,-0.483542677352212f,0.795053306558017f,
-0.246444636768096f,-0.967515102978155f,0.159471890174437f,0.210810164441753f,
-0.874227023772981f,-0.0805964482800334f,0.567497201138046f,-0.137743608785641f,
-0.710773819308763f,-0.589571113738941f,0.83391847788473f,0.474349423613731f,
-0.495444643831966f,-0.415319533683743f,-0.688818445640273f,0.923238489082379f,
0.688452278243922f,-0.639758117768224f,0.353458578584501f,-0.352412753977475f,
-0.667399029986676f,0.586965778853283f,0.352610916528867f,0.360697015758419f,
-0.502839728688848f,-0.539644214882799f,0.365329906944815f,-0.379932106654209f,
-0.269280779163601f,0.694895571222645f,0.727823970732565f,0.51105486079409f,
-0.761212733299821f,-0.551940664095241f,0.953323471475834f,-0.915964879494524f,
0.199091342904332f,0.0392241713497299f,-0.19261671908783f,-0.6074206562147f,
0.345256597791838f,0.031516093623793f,0.563117849295644f,-0.0626584858579093f,
-0.491887339392029f,-0.758788812866925f,0.265995340863064f,0.23182766277084f,
0.069408408971249f,-0.758115582411847f,-0.495213306068685f,-0.941798830898321f,
-0.244099121724069f,-0.496495655783264f,0.217102928532306f,-0.958590442403207f,
-0.951376141167081f,-0.454184666450089f,0.886300276933433f,0.487002988091731f,
0.0249044829036293f,-0.482416930998085f,0.949278378895364f,0.332136035903019f,
0.667897336691517f,-0.903192712329542f,0.0759824890853551f,-0.338269985337703f,
-0.29518903317139f,-0.768719116695905f,-0.648362986306786f,0.935201134387952f,
0.661626711929564f,0.224599917215244f,0.348525351988449f,-0.972641665331466f,
0.996220202383405f,-0.72814219793807f,-0.921619408688976f,-0.134878186992026f,
0.496907260713279f,0.544992091878385f,0.238303715804555f,-0.924062793629034f,
-0.630686074442814f,-0.865452949495847f,-0.222028734920293f,0.171739204767604f,
0.997130539607845f,0.918172604643416f,-0.694626556063078f,0.672880204329672f,
-0.175982089302543f,-0.876546457819273f,-0.699672836718442f,0.809662568756764f,
0.393205100623341f,-0.108144983913576f,-0.486322989569125f,-0.613674712751319f,
-0.317080956716971f,0.471134684264513f,-0.30417867085874f,0.696115419091356f,
-0.469268432777419f,0.236211281027806f,-0.772378939124543f,0.460249824926805f,
-0.654534877200454f,-0.934852798470303f,0.032756384083477f,-0.66677857258658f,
0.314980215822125f,-0.289198088561079f,-0.0476688874127049f,0.0583547444711741f,
0.941740852748786f,0.774296795413221f,-0.414622097461695f,0.638345821607103f,
-0.358465167682304f,-0.700596445490135f,0.374529194857949f,0.45456008092971f,
-0.853620900176985f,0.494280579565469f,-0.217619888424174f,0.956186128386705f,
0.0389822381652678f,-0.19316201021536f,0.00512085504598048f,-0.0427176575011998f,
0.547932129275615f,0.721865358296469f,0.456248153651011f,0.618884232413038f,
0.0410425055490649f,-0.0673903257300594f,-0.218781418704999f,0.528492225462415f,
-0.0837068514807342f,0.718697939323846f,-0.603328224259776f,0.875509849594366f,
-0.0909494938322766f,-0.280637910576161f,-0.645530682341054f,-0.705120660981081f,
-0.529475884017096f,0.140296797228785f,-0.0133440668494202f,0.529843637228154f,
-0.25828493683013f,0.619866268930593f,0.47419437241583f,0.447278725151833f,
0.821711397258731f,-0.617272470973745f,-0.212155578716597f,-0.794533711360103f,
-0.762402399229636f,-0.66554198883216f,0.86799064535122f,-0.61415791629922f,
0.650236475570502f,0.838917668255732f,-0.658036726366966f,0.79973808497526f,
-0.583232188921549f,-0.958456594727579f,-0.670917275207309f,-0.607735262211108f,
0.374114548594356f,0.758519548998692f,-0.831818710697753f,-0.606668498198204f,
0.461609482669083f,0.676995424711095f,0.338856030176508f,0.5967074997629f,
-0.925180531336558f,0.4696830362291f,-0.0384243216844951f,0.649557593176482f,
0.502765260428653f,0.513967467262376f,-0.515358199072217f,-0.444119277197828f,
-0.230720891612428f,0.348053063903166f,0.335781438011331f,0.567805000835321f,
-0.345275268793607f,0.452852845315761f,-0.823034642564643f,-0.629914051647049f,
-0.248509141280827f,0.107760047194603f,0.103293698795021f,0.347988561161273f,
-0.103424145197316f,0.151822355394586f,-0.272890315097335f,0.940838684544033f,
0.174472591496773f,0.741124360281646f,-0.950217097467039f,-0.922017392413252f,
0.496955384825533f,-0.588424819191232f,-0.285012984144181f,-0.292976024259858f,
0.30303004349728f,0.748249196092075f,-0.565826698130202f,0.973592191086922f,
0.598249548946463f,-0.926358493656323f,-0.241048287909827f,0.996364548389252f,
-0.0599127959717052f,0.174629249412504f,-0.96587410625029f,0.980693566420129f,
-0.696388116912935f,-0.900221651108609f,-0.706671628163384f,0.990309443320101f,
-0.585908086908283,0.414355789768166f,0.456957525423029f,-0.308246583228438f,
};
#ifdef _VECTORMATH_SOA_TEST
inline float getfloat( vec_float4 val )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = val;
return tmp.s[0];
}
vec_float4 randfloat()
{
static int randfloat_count = 0;
int idx = randfloat_count;
vec_float4 tmp = (vec_float4){randfloats[idx],randfloats[idx],randfloats[idx],randfloats[idx]};
randfloat_count = (randfloat_count+1) % 1024;
return tmp;
}
#else
inline float getfloat( float val )
{
return val;
}
float randfloat()
{
static int randfloat_count = 0;
float tmp = randfloats[randfloat_count];
randfloat_count = (randfloat_count+1) % 1024;
return tmp;
}
#endif
#ifdef _VECTORMATH_SCALAR_TEST
# define scalar_float(v) (v)
#else
# define scalar_float(v) floatInVec(v)
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,680 @@
set Vector3 with floats: ( 0.465039 -0.479556 -0.211412 )
set Vector3 with floats: ( 0.553580 0.690070 0.151576 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( 0.431077 -0.833992 -0.088350 -0.780106 )
set Vector4 with floats: ( 0.090456 -0.218627 0.137171 0.918133 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( 0.735438 -0.673621 -0.448982 )
set Point3 with floats: ( -0.479278 0.848189 -0.128155 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( 0.578922 -0.744766 -0.835589 0.881284 )
set Quat with floats: ( -0.948850 -0.691578 -0.235635 -0.690527 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
construct Vector3 with Point3: ( 0.735438 -0.673621 -0.448982 )
set Vector3 with float: ( 0.058667 0.058667 0.058667 )
set Vector3 with float: ( 0.753697 0.753697 0.753697 )
aos type 0: ( 9.000000 10.000000 11.000000 )
aos type 1: ( 6.000000 7.000000 8.000000 )
aos type 2: ( 3.000000 4.000000 5.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 )
select 0: ( 0.753697 0.753697 0.753697 )
select 1: ( 0.553580 0.690070 0.151576 )
select 2: ( 0.753697 0.753697 0.753697 )
select 3: ( 0.553580 0.690070 0.151576 )
load XYZ array: ( -0.658344 0.499804 -0.807257 )
xyzx: ( 0.658344 -0.499804 0.807257 -0.740930 )
yzxy: ( -0.154607 -0.571599 -0.384388 0.262467 )
zxyz: ( -0.747808 -0.490190 0.107908 0.292544 )
xyzx: ( 0.658344 -0.499804 0.807257 -0.740930 )
yzxy: ( -0.154607 -0.571599 -0.384388 0.262467 )
zxyz: ( -0.747808 -0.490190 0.107908 0.292544 )
storeXYZ:-1.0 -2.0 -3.0 0.4
assign to Vector3 from Vector3: ( 0.553580 0.690070 0.151576 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set to x axis: ( 1.000000 0.000000 0.000000 )
set to y axis: ( 0.000000 1.000000 0.000000 )
set to z axis: ( 0.000000 0.000000 1.000000 )
Vector3::set( 0, float ): ( -0.138777 0.000000 1.000000 )
Vector3::operator [](0): ( -1.001420 0.000000 1.000000 )
Vector3::setX(): ( 0.410391 0.000000 1.000000 )
Vector3::set( 1, float ): ( 0.410391 -0.562721 1.000000 )
Vector3::operator [](1): ( 0.410391 0.544473 1.000000 )
Vector3::setY(): ( 0.410391 0.374881 1.000000 )
Vector3::set( 2, float ): ( 0.410391 0.374881 -0.127818 )
Vector3::operator [](2): ( 0.410391 0.374881 -0.212598 )
Vector3::setZ(): ( 0.410391 0.374881 -0.723410 )
Vector3::get( 0 ): 0.410391
Vector3::operator []( 0 ): 0.410391
Vector3::getX(): 0.410391
Vector3::get( 1 ): 0.374881
Vector3::operator []( 1 ): 0.374881
Vector3::getY(): 0.374881
Vector3::get( 2 ): -0.723410
Vector3::operator []( 2 ): -0.723410
Vector3::getZ(): -0.723410
Vector3 + Vector3: ( 0.963971 1.064952 -0.571834 )
Vector3 - Vector3: ( -0.143189 -0.315189 -0.874987 )
Vector3 + Point3: ( -0.068887 1.223071 -0.851565 )
Vector3 * float: ( 0.378185 0.345462 -0.666639 )
Vector3 / float: ( -0.577000 -0.527074 1.017097 )
float * Vector3: ( -0.043762 -0.039975 0.077140 )
Vector3 negate: ( -0.410391 -0.374881 0.723410 )
mulPerElem( Vector3, Vector3 ): ( 0.227184 0.258694 -0.109652 )
divPerElem( Vector3, Vector3 ): ( 0.741340 0.543251 -4.772578 )
Vector3 recip: ( 2.436700 2.667511 -1.382342 )
Vector3 sqrt: ( 0.640618 0.612276 0.850535 )
Vector3 rsqrt: ( 1.560993 1.633252 1.175730 )
Vector3 abs: ( 0.410391 0.374881 0.723410 )
Vector3 copySign: ( 0.410391 0.374881 0.723410 )
Vector3 maximum Vector3: ( 0.553580 0.690070 0.151576 )
Vector3 minimum Vector3: ( 0.410391 0.374881 -0.723410 )
Vector3 maximum of elements: 0.410391
Vector3 minimum of elements: -0.723410
Vector3 sum of elements: 0.061862
Vector3 dot Vector3: 0.376227
Vector3 lengthSqr: 0.832279
Vector3 length: 0.912293
Vector3 normalized: ( 0.449846 0.410922 -0.792958 )
Vector3 lerp: ( -0.504755 2.242539 -1.172064 )
Vector3 slerp: ( -0.308956 -0.503372 0.806947 )
set Vector3 with floats: ( 0.932526 0.571087 0.610330 )
set Vector3 with floats: ( 0.142507 -0.434829 0.925102 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( 0.158954 -0.126283 -0.249128 0.846815 )
set Vector4 with floats: ( -0.942601 0.537720 0.446214 0.181939 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( -0.148223 0.284286 0.493525 )
set Point3 with floats: ( -0.861963 -0.893410 0.548627 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( 0.407007 -0.757467 -0.393126 -0.850984 )
set Quat with floats: ( 0.375720 -0.270088 0.458888 -0.610828 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 with Vector3, float: ( 0.932526 0.571087 0.610330 -0.690816 )
set Vector4 with Vector3: ( 0.932526 0.571087 0.610330 0.000000 )
set Vector4 with Point3: ( -0.148223 0.284286 0.493525 1.000000 )
construct Vector4 with Quat: ( 0.407007 -0.757467 -0.393126 -0.850984 )
set Vector4 with float: ( -0.676415 -0.676415 -0.676415 -0.676415 )
set Vector4 with float: ( 0.664466 0.664466 0.664466 0.664466 )
aos type 0: ( 12.000000 13.000000 14.000000 15.000000 )
aos type 1: ( 8.000000 9.000000 10.000000 11.000000 )
aos type 2: ( 4.000000 5.000000 6.000000 7.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 3.000000 )
select 0: ( 0.664466 0.664466 0.664466 0.664466 )
select 1: ( -0.942601 0.537720 0.446214 0.181939 )
select 2: ( 0.664466 0.664466 0.664466 0.664466 )
select 3: ( -0.942601 0.537720 0.446214 0.181939 )
assign to Vector4 from Vector4: ( -0.942601 0.537720 0.446214 0.181939 )
set Vector4 xyz: ( 0.932526 0.571087 0.610330 0.181939 )
get Vector4 xyz: ( 0.932526 0.571087 0.610330 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set to x axis: ( 1.000000 0.000000 0.000000 0.000000 )
set to y axis: ( 0.000000 1.000000 0.000000 0.000000 )
set to z axis: ( 0.000000 0.000000 1.000000 0.000000 )
set to w axis: ( 0.000000 0.000000 0.000000 1.000000 )
Vector4::set( 0, float ): ( 0.101874 0.000000 0.000000 1.000000 )
Vector4::operator [](0): ( -0.879952 0.000000 0.000000 1.000000 )
Vector4::setX(): ( -0.997261 0.000000 0.000000 1.000000 )
Vector4::set( 1, float ): ( -0.997261 0.172409 0.000000 1.000000 )
Vector4::operator [](1): ( -0.997261 0.150201 0.000000 1.000000 )
Vector4::setY(): ( -0.997261 -0.000013 0.000000 1.000000 )
Vector4::set( 2, float ): ( -0.997261 -0.000013 0.689543 1.000000 )
Vector4::operator [](2): ( -0.997261 -0.000013 -0.384253 1.000000 )
Vector4::setZ(): ( -0.997261 -0.000013 -0.801022 1.000000 )
Vector4::set( 3, float ): ( -0.997261 -0.000013 -0.801022 0.656335 )
Vector4::operator [](3): ( -0.997261 -0.000013 -0.801022 16.472569 )
Vector4::setW(): ( -0.997261 -0.000013 -0.801022 0.133022 )
Vector4::get( 0 ): -0.997261
Vector4::operator []( 0 ): -0.997261
Vector4::getX(): -0.997261
Vector4::get( 1 ): -0.000013
Vector4::operator []( 1 ): -0.000013
Vector4::getY(): -0.000013
Vector4::get( 2 ): -0.801022
Vector4::operator []( 2 ): -0.801022
Vector4::getZ(): -0.801022
Vector4::get( 3 ): 0.133022
Vector4::operator []( 3 ): 0.133022
Vector4::getW(): 0.133022
Vector4 + Vector4: ( -1.939863 0.537707 -0.354808 0.314960 )
Vector4 - Vector4: ( -0.054660 -0.537733 -1.247235 -0.048917 )
Vector4 * float: ( 0.052076 0.000001 0.041829 -0.006946 )
Vector4 / float: ( 6.048177 0.000081 4.858026 -0.806748 )
float * Vector4: ( -0.299867 -0.000004 -0.240859 0.039998 )
Vector4 negate: ( 0.997261 0.000013 0.801022 -0.133022 )
mulPerElem( Vector4, Vector4 ): ( 0.940020 -0.000007 -0.357427 0.024202 )
divPerElem( Vector4, Vector4 ): ( 1.057989 -0.000025 -1.795154 0.731134 )
Vector4 recip: ( -1.002746 -75309.887339 -1.248405 7.517576 )
Vector4 sqrt: ( 0.998630 0.003644 0.894998 0.364721 )
Vector4 rsqrt: ( 1.001372 274.426483 1.117321 2.741820 )
Vector4 abs: ( 0.997261 0.000013 0.801022 0.133022 )
Vector4 copySign: ( -0.997261 0.000013 0.801022 0.133022 )
Vector4 maximum Vector4: ( -0.942601 0.537720 0.446214 0.181939 )
Vector4 minimum Vector4: ( -0.997261 -0.000013 -0.801022 0.133022 )
Vector4 maximum of elements: 0.133022
Vector4 minimum of elements: -0.997261
Vector4 sum of elements: -1.665275
Vector4 dot Vector4: 0.606788
Vector4 lengthSqr: 1.653861
Vector4 length: 1.286025
Vector4 normalized: ( -0.775460 -0.000010 -0.622866 0.103436 )
Vector4 lerp: ( -0.226675 0.250339 0.113208 0.735255 )
Vector4 slerp: ( 0.351058 0.199306 -0.276993 0.871958 )
set Vector3 with floats: ( 0.137637 -0.111879 -0.929543 )
set Vector3 with floats: ( -0.336303 -0.146740 0.165140 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( -0.823874 0.349776 0.174872 -0.528584 )
set Vector4 with floats: ( 0.489292 0.916708 0.728511 -0.851140 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( 0.079620 -0.234370 -0.996308 )
set Point3 with floats: ( 0.433229 -0.892684 -0.957911 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( 0.517122 0.257921 0.862028 0.095881 )
set Quat with floats: ( -0.171933 -0.214078 -0.604841 -0.383831 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
construct Point3 with Vector3: ( 0.137637 -0.111879 -0.929543 )
set Point3 with float: ( -0.581500 -0.581500 -0.581500 )
set Point3 with float: ( 0.222183 0.222183 0.222183 )
aos type 0: ( 9.000000 10.000000 11.000000 )
aos type 1: ( 6.000000 7.000000 8.000000 )
aos type 2: ( 3.000000 4.000000 5.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 )
select 0: ( 0.222183 0.222183 0.222183 )
select 1: ( 0.433229 -0.892684 -0.957911 )
select 2: ( 0.222183 0.222183 0.222183 )
select 3: ( 0.433229 -0.892684 -0.957911 )
load XYZ array: ( -0.160082 0.962714 0.737794 )
xyzx: ( 0.160082 -0.962714 -0.737794 0.071926 )
yzxy: ( 0.506313 -0.689277 -0.686485 -0.473013 )
zxyz: ( 0.735610 0.046390 -0.568674 0.004815 )
xyzx: ( 0.160082 -0.962714 -0.737794 0.071926 )
yzxy: ( 0.506313 -0.689277 -0.686485 -0.473013 )
zxyz: ( 0.735610 0.046390 -0.568674 0.004815 )
storeXYZ:-1.0 -2.0 -3.0 0.4
assign to Point3 from Point3: ( 0.433229 -0.892684 -0.957911 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
Point3::set( 0, float ): ( -0.256120 0.000000 0.000000 )
Point3::operator [](0): ( -0.979920 0.000000 0.000000 )
Point3::setX(): ( -0.046627 0.000000 0.000000 )
Point3::set( 1, float ): ( -0.046627 -0.716491 0.000000 )
Point3::operator [](1): ( -0.046627 1.719236 0.000000 )
Point3::setY(): ( -0.046627 0.508814 0.000000 )
Point3::set( 2, float ): ( -0.046627 0.508814 -0.238839 )
Point3::operator [](2): ( -0.046627 0.508814 0.061402 )
Point3::setZ(): ( -0.046627 0.508814 -0.157280 )
Point3::get( 0 ): -0.046627
Point3::operator []( 0 ): -0.046627
Point3::getX(): -0.046627
Point3::get( 1 ): 0.508814
Point3::operator []( 1 ): 0.508814
Point3::getY(): 0.508814
Point3::get( 2 ): -0.157280
Point3::operator []( 2 ): -0.157280
Point3::getZ(): -0.157280
Point3 - Point3: ( -0.479856 1.401498 0.800631 )
Point3 + Vector3: ( -0.382931 0.362074 0.007860 )
Point3 - Vector3: ( 0.289676 0.655554 -0.322420 )
mulPerElem( Point3, Point3 ): ( -0.020200 -0.454210 0.150660 )
divPerElem( Point3, Point3 ): ( -0.107627 -0.569982 0.164191 )
Point3 recip: ( -21.446777 1.965355 -6.358085 )
Point3 sqrt: ( 0.215933 0.713312 0.396586 )
Point3 rsqrt: ( 4.631066 1.401911 2.521524 )
Point3 abs: ( 0.046627 0.508814 0.157280 )
Point3 copySign: ( 0.046627 -0.508814 -0.157280 )
Point3 maximum Point3: ( 0.433229 0.508814 -0.157280 )
Point3 minimum Point3: ( -0.046627 -0.892684 -0.957911 )
Point3 maximum of elements: 0.508814
Point3 minimum of elements: -0.157280
Point3 sum of elements: 0.304907
Point projection: -0.084956
Point distSqrFromOrigin: 0.285803
Point distFromOrigin: 0.534605
Point distSqr: 2.835468
Point dist: 1.683885
Point3 lerp: ( 0.508235 -0.017312 0.360111 )
set Vector3 with floats: ( 0.219317 -0.118359 0.413442 )
set Vector3 with floats: ( -0.567698 0.531358 -0.387226 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( 0.572490 -0.820417 0.797191 0.867178 )
set Vector4 with floats: ( 0.934764 0.237092 -0.866162 -0.773939 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( 0.261311 -0.851570 0.114814 )
set Point3 with floats: ( -0.531592 0.223925 0.869105 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( 0.143405 0.148518 -0.071136 -0.758292 )
set Quat with floats: ( -0.527633 0.997215 0.114440 0.727558 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat with Vector3, float: ( 0.219317 -0.118359 0.413442 -0.425760 )
construct Quat with Vector4: ( 0.572490 -0.820417 0.797191 0.867178 )
set Quat with float: ( 0.459888 0.459888 0.459888 0.459888 )
set Quat with float: ( 0.642516 0.642516 0.642516 0.642516 )
aos type 0: ( 12.000000 13.000000 14.000000 15.000000 )
aos type 1: ( 8.000000 9.000000 10.000000 11.000000 )
aos type 2: ( 4.000000 5.000000 6.000000 7.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 3.000000 )
select 0: ( 0.642516 0.642516 0.642516 0.642516 )
select 1: ( -0.527633 0.997215 0.114440 0.727558 )
select 2: ( 0.642516 0.642516 0.642516 0.642516 )
select 3: ( -0.527633 0.997215 0.114440 0.727558 )
assign to Quat from Quat: ( -0.527633 0.997215 0.114440 0.727558 )
set Quat xyz: ( 0.219317 -0.118359 0.413442 0.727558 )
get Quat xyz: ( 0.219317 -0.118359 0.413442 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
Quat::set( 0, float ): ( -0.022534 0.000000 0.000000 0.000000 )
Quat::operator [](0): ( 0.419714 0.000000 0.000000 0.000000 )
Quat::setX(): ( 0.765986 0.000000 0.000000 0.000000 )
Quat::set( 1, float ): ( 0.765986 -0.137795 0.000000 0.000000 )
Quat::operator [](1): ( 0.765986 0.890273 0.000000 0.000000 )
Quat::setY(): ( 0.765986 -0.553800 0.000000 0.000000 )
Quat::set( 2, float ): ( 0.765986 -0.553800 -0.014688 0.000000 )
Quat::operator [](2): ( 0.765986 -0.553800 -0.802660 0.000000 )
Quat::setZ(): ( 0.765986 -0.553800 0.499529 0.000000 )
Quat::set( 3, float ): ( 0.765986 -0.553800 0.499529 0.385180 )
Quat::operator [](3): ( 0.765986 -0.553800 0.499529 -0.150467 )
Quat::setW(): ( 0.765986 -0.553800 0.499529 0.067637 )
Quat::get( 0 ): 0.765986
Quat::operator []( 0 ): 0.765986
Quat::getX(): 0.765986
Quat::get( 1 ): -0.553800
Quat::operator []( 1 ): -0.553800
Quat::getY(): -0.553800
Quat::get( 2 ): 0.499529
Quat::operator []( 2 ): 0.499529
Quat::getZ(): 0.499529
Quat::get( 3 ): 0.067637
Quat::operator []( 3 ): 0.067637
Quat::getW(): 0.067637
Quat + Quat: ( 0.238353 0.443416 0.613969 0.795196 )
Quat - Quat: ( 1.293620 -1.551015 0.385089 -0.659921 )
Quat * Quat: ( -0.039902 -0.686700 0.842827 0.948461 )
Quat * float: ( 0.611545 -0.442140 0.398812 0.054000 )
Quat / float: ( 2.464705 -1.781954 1.607327 0.217635 )
float * Quat: ( 0.659770 -0.477006 0.430261 0.058258 )
Quat negate: ( -0.765986 0.553800 -0.499529 -0.067637 )
Quat dot Quat: -0.850041
Quat lengthSqr: 1.147533
Quat length: 1.071229
Quat normalized: ( 0.715053 -0.516976 0.466313 0.063140 )
set to identity: ( 0.000000 0.000000 0.000000 1.000000 )
Quat rotation between vectors: ( -0.152187 -0.131117 0.043194 0.571186 )
Quat rotation axis angle: ( -0.103250 0.055721 -0.194639 0.882252 )
Quat rotationX: ( -0.321727 0.000000 0.000000 0.946833 )
Quat rotationY: ( 0.000000 0.142892 0.000000 0.989738 )
Quat rotationZ: ( 0.000000 0.000000 0.262912 0.964820 )
Quat rotate Vector3: ( 0.249044 0.009268 0.413442 )
Quat conj: ( -0.000000 -0.000000 -0.262912 0.964820 )
Quat lerp: ( -0.053419 0.446373 0.392075 0.581368 )
Quat slerp: ( -0.630711 0.472429 0.365730 0.495233 )
Quat squad: ( 0.119307 -0.523957 -0.534187 -0.652594 )
set Vector3 with floats: ( 0.531906 0.271995 -0.862601 )
set Vector3 with floats: ( -0.738694 0.514248 -0.039363 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( 0.429390 -0.769469 0.281336 -0.203301 )
set Vector4 with floats: ( 0.412586 0.567926 0.410131 -0.462918 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( 0.560953 -0.731715 -0.446158 )
set Point3 with floats: ( -0.837491 -0.573480 -0.607820 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( 0.238415 0.213445 0.098612 0.135072 )
set Quat with floats: ( -0.749274 -0.855977 0.765675 -0.693447 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
construct Vector3 with Point3: ( 0.560953 -0.731715 -0.446158 )
set Vector3 with float: ( 0.131554 0.131554 0.131554 )
set Vector3 with float: ( -0.366757 -0.366757 -0.366757 )
aos type 0: ( 9.000000 10.000000 11.000000 )
aos type 1: ( 6.000000 7.000000 8.000000 )
aos type 2: ( 3.000000 4.000000 5.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 )
select 0: ( -0.366757 -0.366757 -0.366757 )
select 1: ( -0.738694 0.514248 -0.039363 )
select 2: ( -0.366757 -0.366757 -0.366757 )
select 3: ( -0.738694 0.514248 -0.039363 )
load XYZ array: ( -0.913636 0.675222 0.144053 )
xyzx: ( 0.913636 -0.675222 -0.144053 0.632329 )
yzxy: ( 0.947120 0.049367 -0.126333 0.664206 )
zxyz: ( -0.220879 -0.284219 0.387216 -0.913568 )
xyzx: ( 0.913636 -0.675222 -0.144053 0.632329 )
yzxy: ( 0.947120 0.049367 -0.126333 0.664206 )
zxyz: ( -0.220879 -0.284219 0.387216 -0.913568 )
storeXYZ:-1.0 -2.0 -3.0 0.4
assign to Vector3 from Vector3: ( -0.738694 0.514248 -0.039363 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set to x axis: ( 1.000000 0.000000 0.000000 )
set to y axis: ( 0.000000 1.000000 0.000000 )
set to z axis: ( 0.000000 0.000000 1.000000 )
Vector3::set( 0, float ): ( -0.330409 0.000000 1.000000 )
Vector3::operator [](0): ( -1.321680 0.000000 1.000000 )
Vector3::setX(): ( -0.870739 0.000000 1.000000 )
Vector3::set( 1, float ): ( -0.870739 0.415605 1.000000 )
Vector3::operator [](1): ( -0.870739 -0.855146 1.000000 )
Vector3::setY(): ( -0.870739 0.876855 1.000000 )
Vector3::set( 2, float ): ( -0.870739 0.876855 0.982846 )
Vector3::operator [](2): ( -0.870739 0.876855 -0.725814 )
Vector3::setZ(): ( -0.870739 0.876855 -0.123567 )
Vector3::get( 0 ): -0.870739
Vector3::operator []( 0 ): -0.870739
Vector3::getX(): -0.870739
Vector3::get( 1 ): 0.876855
Vector3::operator []( 1 ): 0.876855
Vector3::getY(): 0.876855
Vector3::get( 2 ): -0.123567
Vector3::operator []( 2 ): -0.123567
Vector3::getZ(): -0.123567
Vector3 + Vector3: ( -1.609433 1.391104 -0.162930 )
Vector3 - Vector3: ( -0.132046 0.362607 -0.084203 )
Vector3 + Point3: ( -1.708231 0.303375 -0.731387 )
Vector3 * float: ( -0.354427 0.356917 -0.050297 )
Vector3 / float: ( -6.166518 6.209829 -0.875092 )
float * Vector3: ( 0.690557 -0.695407 0.097997 )
Vector3 negate: ( 0.870739 -0.876855 0.123567 )
mulPerElem( Vector3, Vector3 ): ( 0.643210 0.450921 0.004864 )
divPerElem( Vector3, Vector3 ): ( 1.178756 1.705119 3.139138 )
Vector3 recip: ( -1.148449 1.140439 -8.092791 )
Vector3 sqrt: ( 0.933134 0.936405 0.351521 )
Vector3 rsqrt: ( 1.071657 1.067914 2.844783 )
Vector3 abs: ( 0.870739 0.876855 0.123567 )
Vector3 copySign: ( -0.870739 0.876855 -0.123567 )
Vector3 maximum Vector3: ( -0.738694 0.876855 -0.039363 )
Vector3 minimum Vector3: ( -0.870739 0.514248 -0.123567 )
Vector3 maximum of elements: 0.876855
Vector3 minimum of elements: -0.870739
Vector3 sum of elements: -0.117451
Vector3 dot Vector3: 1.098995
Vector3 lengthSqr: 1.542330
Vector3 length: 1.241906
Vector3 normalized: ( -0.701131 0.706056 -0.099498 )
Vector3 lerp: ( -0.118997 -0.338092 0.499550 )
Vector3 slerp: ( -0.899759 -0.236062 -0.367027 )
set Vector3 with floats: ( 0.060414 -0.867395 -0.702364 )
set Vector3 with floats: ( -0.182602 -0.832807 0.278191 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( -0.967562 -0.520296 0.160191 -0.677990 )
set Vector4 with floats: ( -0.470750 -0.846580 -0.705751 -0.825368 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( -0.712890 -0.064487 0.444065 )
set Point3 with floats: ( -0.045226 0.116544 -0.007285 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( -0.838230 -0.410767 -0.409299 -0.336683 )
set Quat with floats: ( -0.830700 -0.801729 -0.595153 -0.784672 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 with Vector3, float: ( 0.060414 -0.867395 -0.702364 -0.653655 )
set Vector4 with Vector3: ( 0.060414 -0.867395 -0.702364 0.000000 )
set Vector4 with Point3: ( -0.712890 -0.064487 0.444065 1.000000 )
construct Vector4 with Quat: ( -0.838230 -0.410767 -0.409299 -0.336683 )
set Vector4 with float: ( 0.670791 0.670791 0.670791 0.670791 )
set Vector4 with float: ( 0.653571 0.653571 0.653571 0.653571 )
aos type 0: ( 12.000000 13.000000 14.000000 15.000000 )
aos type 1: ( 8.000000 9.000000 10.000000 11.000000 )
aos type 2: ( 4.000000 5.000000 6.000000 7.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 3.000000 )
select 0: ( 0.653571 0.653571 0.653571 0.653571 )
select 1: ( -0.470750 -0.846580 -0.705751 -0.825368 )
select 2: ( 0.653571 0.653571 0.653571 0.653571 )
select 3: ( -0.470750 -0.846580 -0.705751 -0.825368 )
assign to Vector4 from Vector4: ( -0.470750 -0.846580 -0.705751 -0.825368 )
set Vector4 xyz: ( 0.060414 -0.867395 -0.702364 -0.825368 )
get Vector4 xyz: ( 0.060414 -0.867395 -0.702364 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set to x axis: ( 1.000000 0.000000 0.000000 0.000000 )
set to y axis: ( 0.000000 1.000000 0.000000 0.000000 )
set to z axis: ( 0.000000 0.000000 1.000000 0.000000 )
set to w axis: ( 0.000000 0.000000 0.000000 1.000000 )
Vector4::set( 0, float ): ( 0.850716 0.000000 0.000000 1.000000 )
Vector4::operator [](0): ( -0.528836 0.000000 0.000000 1.000000 )
Vector4::setX(): ( 0.965901 0.000000 0.000000 1.000000 )
Vector4::set( 1, float ): ( 0.965901 -0.072675 0.000000 1.000000 )
Vector4::operator [](1): ( 0.965901 0.450700 0.000000 1.000000 )
Vector4::setY(): ( 0.965901 -0.825793 0.000000 1.000000 )
Vector4::set( 2, float ): ( 0.965901 -0.825793 0.597719 1.000000 )
Vector4::operator [](2): ( 0.965901 -0.825793 0.279622 1.000000 )
Vector4::setZ(): ( 0.965901 -0.825793 -0.884427 1.000000 )
Vector4::set( 3, float ): ( 0.965901 -0.825793 -0.884427 -0.756791 )
Vector4::operator [](3): ( 0.965901 -0.825793 -0.884427 -0.685697 )
Vector4::setW(): ( 0.965901 -0.825793 -0.884427 -0.684626 )
Vector4::get( 0 ): 0.965901
Vector4::operator []( 0 ): 0.965901
Vector4::getX(): 0.965901
Vector4::get( 1 ): -0.825793
Vector4::operator []( 1 ): -0.825793
Vector4::getY(): -0.825793
Vector4::get( 2 ): -0.884427
Vector4::operator []( 2 ): -0.884427
Vector4::getZ(): -0.884427
Vector4::get( 3 ): -0.684626
Vector4::operator []( 3 ): -0.684626
Vector4::getW(): -0.684626
Vector4 + Vector4: ( 0.495151 -1.672373 -1.590178 -1.509993 )
Vector4 - Vector4: ( 1.436652 0.020787 -0.178676 0.140742 )
Vector4 * float: ( -0.960151 0.820877 0.879161 0.680550 )
Vector4 / float: ( 1.206825 -1.031770 -1.105029 -0.855391 )
float * Vector4: ( -0.546353 0.467102 0.500267 0.387252 )
Vector4 negate: ( -0.965901 0.825793 0.884427 0.684626 )
mulPerElem( Vector4, Vector4 ): ( -0.454698 0.699100 0.624185 0.565068 )
divPerElem( Vector4, Vector4 ): ( -2.051834 0.975446 1.253172 0.829480 )
Vector4 recip: ( 1.035302 -1.210957 -1.130676 -1.460652 )
Vector4 sqrt: ( 0.982803 0.908731 0.940440 0.827421 )
Vector4 rsqrt: ( 1.017498 1.100435 1.063332 1.208575 )
Vector4 abs: ( 0.965901 0.825793 0.884427 0.684626 )
Vector4 copySign: ( -0.965901 -0.825793 -0.884427 -0.684626 )
Vector4 maximum Vector4: ( 0.965901 -0.825793 -0.705751 -0.684626 )
Vector4 minimum Vector4: ( -0.470750 -0.846580 -0.884427 -0.825368 )
Vector4 maximum of elements: 0.965901
Vector4 minimum of elements: -0.884427
Vector4 sum of elements: -1.428944
Vector4 dot Vector4: 1.433654
Vector4 lengthSqr: 2.865822
Vector4 length: 1.692874
Vector4 normalized: ( 0.570569 -0.487805 -0.522441 -0.404416 )
Vector4 lerp: ( -0.436271 0.676982 0.475175 0.275280 )
Vector4 slerp: ( -0.493672 0.661673 0.416222 0.381100 )
set Vector3 with floats: ( -0.287826 0.942655 -0.634432 )
set Vector3 with floats: ( -0.140438 0.570869 -0.764965 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( 0.067523 -0.514589 0.233091 0.554488 )
set Vector4 with floats: ( -0.633529 -0.019374 0.869259 -0.369818 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( -0.280690 -0.797209 -0.255233 )
set Point3 with floats: ( 0.780605 0.789803 0.974262 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( -0.785980 -0.701386 0.871088 0.566743 )
set Quat with floats: ( 0.752273 -0.476301 -0.747342 0.077386 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
construct Point3 with Vector3: ( -0.287826 0.942655 -0.634432 )
set Point3 with float: ( -0.305600 -0.305600 -0.305600 )
set Point3 with float: ( -0.229194 -0.229194 -0.229194 )
aos type 0: ( 9.000000 10.000000 11.000000 )
aos type 1: ( 6.000000 7.000000 8.000000 )
aos type 2: ( 3.000000 4.000000 5.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 )
select 0: ( -0.229194 -0.229194 -0.229194 )
select 1: ( 0.780605 0.789803 0.974262 )
select 2: ( -0.229194 -0.229194 -0.229194 )
select 3: ( 0.780605 0.789803 0.974262 )
load XYZ array: ( 0.376026 -0.935045 -0.189804 )
xyzx: ( -0.376026 0.935045 0.189804 -0.007649 )
yzxy: ( 0.440298 -0.994796 0.271484 0.259070 )
zxyz: ( -0.902149 0.836501 -0.229093 -0.586393 )
xyzx: ( -0.376026 0.935045 0.189804 -0.007649 )
yzxy: ( 0.440298 -0.994796 0.271484 0.259070 )
zxyz: ( -0.902149 0.836501 -0.229093 -0.586393 )
storeXYZ:-1.0 -2.0 -3.0 0.4
assign to Point3 from Point3: ( 0.780605 0.789803 0.974262 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
Point3::set( 0, float ): ( -0.260009 0.000000 0.000000 )
Point3::operator [](0): ( 0.017680 0.000000 0.000000 )
Point3::setX(): ( 0.912886 0.000000 0.000000 )
Point3::set( 1, float ): ( 0.912886 -0.402380 0.000000 )
Point3::operator [](1): ( 0.912886 1.043836 0.000000 )
Point3::setY(): ( 0.912886 0.321576 0.000000 )
Point3::set( 2, float ): ( 0.912886 0.321576 0.724026 )
Point3::operator [](2): ( 0.912886 0.321576 -0.074816 )
Point3::setZ(): ( 0.912886 0.321576 0.137730 )
Point3::get( 0 ): 0.912886
Point3::operator []( 0 ): 0.912886
Point3::getX(): 0.912886
Point3::get( 1 ): 0.321576
Point3::operator []( 1 ): 0.321576
Point3::getY(): 0.321576
Point3::get( 2 ): 0.137730
Point3::operator []( 2 ): 0.137730
Point3::getZ(): 0.137730
Point3 - Point3: ( 0.132280 -0.468228 -0.836532 )
Point3 + Vector3: ( 0.772448 0.892445 -0.627235 )
Point3 - Vector3: ( 1.053323 -0.249293 0.902695 )
mulPerElem( Point3, Point3 ): ( 0.712603 0.253982 0.134185 )
divPerElem( Point3, Point3 ): ( 1.169459 0.407159 0.141368 )
Point3 recip: ( 1.095427 3.109689 7.260596 )
Point3 sqrt: ( 0.955451 0.567076 0.371120 )
Point3 rsqrt: ( 1.046627 1.763431 2.694549 )
Point3 abs: ( 0.912886 0.321576 0.137730 )
Point3 copySign: ( 0.912886 0.321576 0.137730 )
Point3 maximum Point3: ( 0.912886 0.789803 0.974262 )
Point3 minimum Point3: ( 0.780605 0.321576 0.137730 )
Point3 maximum of elements: 0.912886
Point3 minimum of elements: 0.137730
Point3 sum of elements: 1.372191
Point projection: -0.049984
Point distSqrFromOrigin: 0.955741
Point distFromOrigin: 0.977620
Point distSqr: 0.936521
Point dist: 0.967740
Point3 lerp: ( -0.148533 -0.240318 0.263234 )
set Vector3 with floats: ( -0.950919 -0.196258 -0.599808 )
set Vector3 with floats: ( -0.794413 -0.927636 -0.187478 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Vector4 with floats: ( -0.113038 0.366120 -0.483786 0.622670 )
set Vector4 with floats: ( -0.801806 0.295383 0.022005 -0.000678 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Point3 with floats: ( -0.689334 0.266538 -0.785099 )
set Point3 with floats: ( -0.572665 0.772760 0.971896 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Point3 elements to zero: ( 0.000000 0.000000 0.000000 )
set Quat with floats: ( -0.961363 0.723449 -0.758442 -0.733158 )
set Quat with floats: ( 0.139667 -0.738147 0.727224 0.089921 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
set Quat with Vector3, float: ( -0.950919 -0.196258 -0.599808 -0.113118 )
construct Quat with Vector4: ( -0.113038 0.366120 -0.483786 0.622670 )
set Quat with float: ( -0.364554 -0.364554 -0.364554 -0.364554 )
set Quat with float: ( -0.137645 -0.137645 -0.137645 -0.137645 )
aos type 0: ( 12.000000 13.000000 14.000000 15.000000 )
aos type 1: ( 8.000000 9.000000 10.000000 11.000000 )
aos type 2: ( 4.000000 5.000000 6.000000 7.000000 )
aos type 3: ( 0.000000 1.000000 2.000000 3.000000 )
select 0: ( -0.137645 -0.137645 -0.137645 -0.137645 )
select 1: ( 0.139667 -0.738147 0.727224 0.089921 )
select 2: ( -0.137645 -0.137645 -0.137645 -0.137645 )
select 3: ( 0.139667 -0.738147 0.727224 0.089921 )
assign to Quat from Quat: ( 0.139667 -0.738147 0.727224 0.089921 )
set Quat xyz: ( -0.950919 -0.196258 -0.599808 0.089921 )
get Quat xyz: ( -0.950919 -0.196258 -0.599808 )
set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 )
Quat::set( 0, float ): ( 0.933847 0.000000 0.000000 0.000000 )
Quat::operator [](0): ( 2.026584 0.000000 0.000000 0.000000 )
Quat::setX(): ( -0.069558 0.000000 0.000000 0.000000 )
Quat::set( 1, float ): ( -0.069558 -0.216369 0.000000 0.000000 )
Quat::operator [](1): ( -0.069558 -0.152646 0.000000 0.000000 )
Quat::setY(): ( -0.069558 -0.022250 0.000000 0.000000 )
Quat::set( 2, float ): ( -0.069558 -0.022250 0.035410 0.000000 )
Quat::operator [](2): ( -0.069558 -0.022250 1.428823 0.000000 )
Quat::setZ(): ( -0.069558 -0.022250 0.804061 0.000000 )
Quat::set( 3, float ): ( -0.069558 -0.022250 0.804061 0.161693 )
Quat::operator [](3): ( -0.069558 -0.022250 0.804061 -0.332169 )
Quat::setW(): ( -0.069558 -0.022250 0.804061 -0.586017 )
Quat::get( 0 ): -0.069558
Quat::operator []( 0 ): -0.069558
Quat::getX(): -0.069558
Quat::get( 1 ): -0.022250
Quat::operator []( 1 ): -0.022250
Quat::getY(): -0.022250
Quat::get( 2 ): 0.804061
Quat::operator []( 2 ): 0.804061
Quat::getZ(): 0.804061
Quat::get( 3 ): -0.586017
Quat::operator []( 3 ): -0.586017
Quat::getW(): -0.586017
Quat + Quat: ( 0.070108 -0.760397 1.531285 -0.496095 )
Quat - Quat: ( -0.209225 0.715896 0.076837 -0.675938 )
Quat * Quat: ( 0.489232 0.593451 -0.299411 -0.644137 )
Quat * float: ( -0.031036 -0.009928 0.358759 -0.261471 )
Quat / float: ( -0.103711 -0.033175 1.198842 -0.873742 )
float * Quat: ( 0.021745 0.006956 -0.251360 0.183196 )
Quat negate: ( 0.069558 0.022250 -0.804061 0.586017 )
Quat dot Quat: 0.538746
Quat lengthSqr: 0.995263
Quat length: 0.997629
Quat normalized: ( -0.069724 -0.022303 0.805972 -0.587410 )
set to identity: ( 0.000000 0.000000 0.000000 1.000000 )
Quat rotation between vectors: ( -0.256621 0.147283 0.358649 1.012405 )
Quat rotation axis angle: ( 0.163854 0.033817 0.103354 0.985043 )
Quat rotationX: ( -0.160489 0.000000 0.000000 0.987038 )
Quat rotationY: ( 0.000000 0.030795 0.000000 0.999526 )
Quat rotationZ: ( 0.000000 0.000000 0.054406 0.998519 )
Quat rotate Vector3: ( -0.923966 -0.298415 -0.599808 )
Quat conj: ( -0.000000 -0.000000 -0.054406 0.998519 )
Quat lerp: ( -0.860671 -0.101017 0.008389 -0.459099 )
Quat slerp: ( -0.935192 0.097684 -0.079386 -0.331015 )
Quat squad: ( -0.208138 -0.281808 0.458751 -0.816585 )
__end__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,931 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Soa;
void
Vector3_methods_test()
{
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat;
Aos::Vector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3;
Vector3 soa_Vector3;
Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4;
float xyz4[12] __attribute__ ((aligned(16)));
xyz4[0] = getfloat(randfloat());
xyz4[1] = getfloat(randfloat());
xyz4[2] = getfloat(randfloat());
xyz4[3] = getfloat(randfloat());
xyz4[4] = getfloat(randfloat());
xyz4[5] = getfloat(randfloat());
xyz4[6] = getfloat(randfloat());
xyz4[7] = getfloat(randfloat());
xyz4[8] = getfloat(randfloat());
xyz4[9] = getfloat(randfloat());
xyz4[10] = getfloat(randfloat());
xyz4[11] = getfloat(randfloat());
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
c_Vector3 = Vector3( (vec_float4){0.0f} );
d_Vector3 = Vector3( (vec_float4){0.0f} );
e_Vector3 = Vector3( (vec_float4){0.0f} );
print( c_Vector3, "set Vector3 elements to zero" );
print( d_Vector3, "set Vector3 elements to zero" );
print( e_Vector3, "set Vector3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
c_Vector4 = Vector4( (vec_float4){0.0f} );
d_Vector4 = Vector4( (vec_float4){0.0f} );
e_Vector4 = Vector4( (vec_float4){0.0f} );
print( c_Vector4, "set Vector4 elements to zero" );
print( d_Vector4, "set Vector4 elements to zero" );
print( e_Vector4, "set Vector4 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
c_Point3 = Point3( (vec_float4){0.0f} );
d_Point3 = Point3( (vec_float4){0.0f} );
e_Point3 = Point3( (vec_float4){0.0f} );
print( c_Point3, "set Point3 elements to zero" );
print( d_Point3, "set Point3 elements to zero" );
print( e_Point3, "set Point3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
c_Quat = Quat( (vec_float4){0.0f} );
d_Quat = Quat( (vec_float4){0.0f} );
e_Quat = Quat( (vec_float4){0.0f} );
print( c_Quat, "set Quat elements to zero" );
print( d_Quat, "set Quat elements to zero" );
print( e_Quat, "set Quat elements to zero" );
a_Vector3 = Vector3( a_Point3 );
print( a_Vector3, "construct Vector3 with Point3" );
a_Vector3 = Vector3( randfloat() );
print( a_Vector3, "set Vector3 with float" );
a_Vector3 = Vector3( randfloat() );
print( a_Vector3, "set Vector3 with float" );
aos_Vector3_0 = Aos::Vector3( 0.0f, 1.0f, 2.0f );
aos_Vector3_1 = Aos::Vector3( 3.0f, 4.0f, 5.0f );
aos_Vector3_2 = Aos::Vector3( 6.0f, 7.0f, 8.0f );
aos_Vector3_3 = Aos::Vector3( 9.0f, 10.0f, 11.0f );
soa_Vector3 = Vector3( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 );
soa_Vector3.get4Aos( aos_Vector3_3, aos_Vector3_2, aos_Vector3_1, aos_Vector3_0 );
Aos::print( aos_Vector3_0, "aos type 0" );
Aos::print( aos_Vector3_1, "aos type 1" );
Aos::print( aos_Vector3_2, "aos type 2" );
Aos::print( aos_Vector3_3, "aos type 3" );
a_Vector3 = select( a_Vector3, b_Vector3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) );
a_Vector3.get4Aos( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 );
Aos::print( aos_Vector3_0, "select 0" );
Aos::print( aos_Vector3_1, "select 1" );
Aos::print( aos_Vector3_2, "select 2" );
Aos::print( aos_Vector3_3, "select 3" );
loadXYZArray( a_Vector3, (const vec_float4 *)xyz4 );
print( a_Vector3, "load XYZ array" );
a_Vector3 = Vector3( ( -Vector3( a_Vector3 ) ) );
storeXYZArray( a_Vector3, (vec_float4 *)xyz4 );
aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] );
aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] );
aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] );
Aos::print( aos_Vector4_0, "xyzx" );
Aos::print( aos_Vector4_1, "yzxy" );
Aos::print( aos_Vector4_2, "zxyz" );
Aos::print( aos_Vector4_0, "xyzx" );
Aos::print( aos_Vector4_1, "yzxy" );
Aos::print( aos_Vector4_2, "zxyz" );
printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n");
a_Vector3 = b_Vector3;
print( a_Vector3, "assign to Vector3 from Vector3" );
a_Vector3 = Vector3( (vec_float4){0.0f} );
print( a_Vector3, "set Vector3 elements to zero" );
a_Vector3 = Vector3::xAxis( );
print( a_Vector3, "set to x axis" );
a_Vector3 = Vector3::yAxis( );
print( a_Vector3, "set to y axis" );
a_Vector3 = Vector3::zAxis( );
print( a_Vector3, "set to z axis" );
a_Vector3.setElem( 0, randfloat() );
print( a_Vector3, "Vector3::set( 0, float )" );
a_Vector3[0] = randfloat();
a_Vector3[0] = vec_mul_float( a_Vector3[0], randfloat() );
a_Vector3[0] = divf4( a_Vector3[0], randfloat() );
a_Vector3[0] = vec_add_float( a_Vector3[0], randfloat() );
a_Vector3[0] = vec_sub_float( a_Vector3[0], randfloat() );
print( a_Vector3, "Vector3::operator [](0)" );
a_Vector3.setX( randfloat() );
print( a_Vector3, "Vector3::setX()" );
a_Vector3.setElem( 1, randfloat() );
print( a_Vector3, "Vector3::set( 1, float )" );
a_Vector3[1] = randfloat();
a_Vector3[1] = vec_mul_float( a_Vector3[1], randfloat() );
a_Vector3[1] = divf4( a_Vector3[1], randfloat() );
a_Vector3[1] = vec_add_float( a_Vector3[1], randfloat() );
a_Vector3[1] = vec_sub_float( a_Vector3[1], randfloat() );
print( a_Vector3, "Vector3::operator [](1)" );
a_Vector3.setY( randfloat() );
print( a_Vector3, "Vector3::setY()" );
a_Vector3.setElem( 2, randfloat() );
print( a_Vector3, "Vector3::set( 2, float )" );
a_Vector3[2] = randfloat();
a_Vector3[2] = vec_mul_float( a_Vector3[2], randfloat() );
a_Vector3[2] = divf4( a_Vector3[2], randfloat() );
a_Vector3[2] = vec_add_float( a_Vector3[2], randfloat() );
a_Vector3[2] = vec_sub_float( a_Vector3[2], randfloat() );
print( a_Vector3, "Vector3::operator [](2)" );
a_Vector3.setZ( randfloat() );
print( a_Vector3, "Vector3::setZ()" );
printf("Vector3::get( 0 ): %f\n", getfloat(a_Vector3.getElem( 0 )) );
printf("Vector3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector3[0]) );
printf("Vector3::getX(): %f\n", getfloat(a_Vector3.getX( )) );
printf("Vector3::get( 1 ): %f\n", getfloat(a_Vector3.getElem( 1 )) );
printf("Vector3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector3[1]) );
printf("Vector3::getY(): %f\n", getfloat(a_Vector3.getY( )) );
printf("Vector3::get( 2 ): %f\n", getfloat(a_Vector3.getElem( 2 )) );
printf("Vector3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector3[2]) );
printf("Vector3::getZ(): %f\n", getfloat(a_Vector3.getZ( )) );
print( ( a_Vector3 + b_Vector3 ), "Vector3 + Vector3" );
print( ( a_Vector3 - b_Vector3 ), "Vector3 - Vector3" );
print( ( a_Vector3 + b_Point3 ), "Vector3 + Point3" );
print( ( a_Vector3 * randfloat() ), "Vector3 * float" );
print( ( a_Vector3 / randfloat() ), "Vector3 / float" );
print( ( randfloat() * a_Vector3 ), "float * Vector3" );
print( ( -a_Vector3 ), "Vector3 negate" );
print( mulPerElem( a_Vector3, b_Vector3 ), "mulPerElem( Vector3, Vector3 )" );
print( divPerElem( a_Vector3, b_Vector3 ), "divPerElem( Vector3, Vector3 )" );
print( recipPerElem( a_Vector3 ), "Vector3 recip" );
print( sqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 sqrt" );
print( rsqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 rsqrt" );
print( absPerElem( a_Vector3 ), "Vector3 abs" );
print( copySignPerElem( a_Vector3, b_Vector3 ), "Vector3 copySign" );
print( maxPerElem( a_Vector3, b_Vector3 ), "Vector3 maximum Vector3" );
print( minPerElem( a_Vector3, b_Vector3 ), "Vector3 minimum Vector3" );
printf("Vector3 maximum of elements: %f\n", getfloat(maxElem( a_Vector3 )));
printf("Vector3 minimum of elements: %f\n", getfloat(minElem( a_Vector3 )));
printf("Vector3 sum of elements: %f\n", getfloat(sum( a_Vector3 )));
printf("Vector3 dot Vector3: %f\n", getfloat(dot( a_Vector3, b_Vector3 )));
printf("Vector3 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector3 )));
printf("Vector3 length: %f\n", getfloat(length( a_Vector3 )));
print( normalize( a_Vector3 ), "Vector3 normalized" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
e_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
b_Vector3 = normalize( b_Vector3 );
c_Vector3 = normalize( c_Vector3 );
d_Vector3 = normalize( d_Vector3 );
e_Vector3 = normalize( e_Vector3 );
a_Vector3 = lerp( randfloat(), b_Vector3, c_Vector3 );
print( a_Vector3, "Vector3 lerp" );
a_Vector3 = slerp( randfloat(), b_Vector3, c_Vector3 );
print( a_Vector3, "Vector3 slerp" );
}
void
Vector4_methods_test()
{
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat;
Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3;
Vector4 soa_Vector4;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
c_Vector3 = Vector3( (vec_float4){0.0f} );
d_Vector3 = Vector3( (vec_float4){0.0f} );
e_Vector3 = Vector3( (vec_float4){0.0f} );
print( c_Vector3, "set Vector3 elements to zero" );
print( d_Vector3, "set Vector3 elements to zero" );
print( e_Vector3, "set Vector3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
c_Vector4 = Vector4( (vec_float4){0.0f} );
d_Vector4 = Vector4( (vec_float4){0.0f} );
e_Vector4 = Vector4( (vec_float4){0.0f} );
print( c_Vector4, "set Vector4 elements to zero" );
print( d_Vector4, "set Vector4 elements to zero" );
print( e_Vector4, "set Vector4 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
c_Point3 = Point3( (vec_float4){0.0f} );
d_Point3 = Point3( (vec_float4){0.0f} );
e_Point3 = Point3( (vec_float4){0.0f} );
print( c_Point3, "set Point3 elements to zero" );
print( d_Point3, "set Point3 elements to zero" );
print( e_Point3, "set Point3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
c_Quat = Quat( (vec_float4){0.0f} );
d_Quat = Quat( (vec_float4){0.0f} );
e_Quat = Quat( (vec_float4){0.0f} );
print( c_Quat, "set Quat elements to zero" );
print( d_Quat, "set Quat elements to zero" );
print( e_Quat, "set Quat elements to zero" );
a_Vector4 = Vector4( a_Vector3, randfloat() );
print( a_Vector4, "set Vector4 with Vector3, float" );
a_Vector4 = Vector4( a_Vector3 );
print( a_Vector4, "set Vector4 with Vector3" );
a_Vector4 = Vector4( a_Point3 );
print( a_Vector4, "set Vector4 with Point3" );
a_Vector4 = Vector4( a_Quat );
print( a_Vector4, "construct Vector4 with Quat" );
a_Vector4 = Vector4( randfloat() );
print( a_Vector4, "set Vector4 with float" );
a_Vector4 = Vector4( randfloat() );
print( a_Vector4, "set Vector4 with float" );
aos_Vector4_0 = Aos::Vector4( 0.0f, 1.0f, 2.0f, 3.0f );
aos_Vector4_1 = Aos::Vector4( 4.0f, 5.0f, 6.0f, 7.0f );
aos_Vector4_2 = Aos::Vector4( 8.0f, 9.0f, 10.0f, 11.0f );
aos_Vector4_3 = Aos::Vector4( 12.0f, 13.0f, 14.0f, 15.0f );
soa_Vector4 = Vector4( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 );
soa_Vector4.get4Aos( aos_Vector4_3, aos_Vector4_2, aos_Vector4_1, aos_Vector4_0 );
Aos::print( aos_Vector4_0, "aos type 0" );
Aos::print( aos_Vector4_1, "aos type 1" );
Aos::print( aos_Vector4_2, "aos type 2" );
Aos::print( aos_Vector4_3, "aos type 3" );
a_Vector4 = select( a_Vector4, b_Vector4, ((vec_uint4){0,0xffffffff,0,0xffffffff}) );
a_Vector4.get4Aos( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 );
Aos::print( aos_Vector4_0, "select 0" );
Aos::print( aos_Vector4_1, "select 1" );
Aos::print( aos_Vector4_2, "select 2" );
Aos::print( aos_Vector4_3, "select 3" );
a_Vector4 = b_Vector4;
print( a_Vector4, "assign to Vector4 from Vector4" );
a_Vector4.setXYZ( a_Vector3 );
print( a_Vector4, "set Vector4 xyz" );
print( a_Vector4.getXYZ( ), "get Vector4 xyz" );
a_Vector4 = Vector4( (vec_float4){0.0f} );
print( a_Vector4, "set Vector4 elements to zero" );
a_Vector4 = Vector4::xAxis( );
print( a_Vector4, "set to x axis" );
a_Vector4 = Vector4::yAxis( );
print( a_Vector4, "set to y axis" );
a_Vector4 = Vector4::zAxis( );
print( a_Vector4, "set to z axis" );
a_Vector4 = Vector4::wAxis( );
print( a_Vector4, "set to w axis" );
a_Vector4.setElem( 0, randfloat() );
print( a_Vector4, "Vector4::set( 0, float )" );
a_Vector4[0] = randfloat();
a_Vector4[0] = vec_mul_float( a_Vector4[0], randfloat() );
a_Vector4[0] = divf4( a_Vector4[0], randfloat() );
a_Vector4[0] = vec_add_float( a_Vector4[0], randfloat() );
a_Vector4[0] = vec_sub_float( a_Vector4[0], randfloat() );
print( a_Vector4, "Vector4::operator [](0)" );
a_Vector4.setX( randfloat() );
print( a_Vector4, "Vector4::setX()" );
a_Vector4.setElem( 1, randfloat() );
print( a_Vector4, "Vector4::set( 1, float )" );
a_Vector4[1] = randfloat();
a_Vector4[1] = vec_mul_float( a_Vector4[1], randfloat() );
a_Vector4[1] = divf4( a_Vector4[1], randfloat() );
a_Vector4[1] = vec_add_float( a_Vector4[1], randfloat() );
a_Vector4[1] = vec_sub_float( a_Vector4[1], randfloat() );
print( a_Vector4, "Vector4::operator [](1)" );
a_Vector4.setY( randfloat() );
print( a_Vector4, "Vector4::setY()" );
a_Vector4.setElem( 2, randfloat() );
print( a_Vector4, "Vector4::set( 2, float )" );
a_Vector4[2] = randfloat();
a_Vector4[2] = vec_mul_float( a_Vector4[2], randfloat() );
a_Vector4[2] = divf4( a_Vector4[2], randfloat() );
a_Vector4[2] = vec_add_float( a_Vector4[2], randfloat() );
a_Vector4[2] = vec_sub_float( a_Vector4[2], randfloat() );
print( a_Vector4, "Vector4::operator [](2)" );
a_Vector4.setZ( randfloat() );
print( a_Vector4, "Vector4::setZ()" );
a_Vector4.setElem( 3, randfloat() );
print( a_Vector4, "Vector4::set( 3, float )" );
a_Vector4[3] = randfloat();
a_Vector4[3] = vec_mul_float( a_Vector4[3], randfloat() );
a_Vector4[3] = divf4( a_Vector4[3], randfloat() );
a_Vector4[3] = vec_add_float( a_Vector4[3], randfloat() );
a_Vector4[3] = vec_sub_float( a_Vector4[3], randfloat() );
print( a_Vector4, "Vector4::operator [](3)" );
a_Vector4.setW( randfloat() );
print( a_Vector4, "Vector4::setW()" );
printf("Vector4::get( 0 ): %f\n", getfloat(a_Vector4.getElem( 0 )) );
printf("Vector4::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector4[0]) );
printf("Vector4::getX(): %f\n", getfloat(a_Vector4.getX( )) );
printf("Vector4::get( 1 ): %f\n", getfloat(a_Vector4.getElem( 1 )) );
printf("Vector4::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector4[1]) );
printf("Vector4::getY(): %f\n", getfloat(a_Vector4.getY( )) );
printf("Vector4::get( 2 ): %f\n", getfloat(a_Vector4.getElem( 2 )) );
printf("Vector4::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector4[2]) );
printf("Vector4::getZ(): %f\n", getfloat(a_Vector4.getZ( )) );
printf("Vector4::get( 3 ): %f\n", getfloat(a_Vector4.getElem( 3 )) );
printf("Vector4::operator []( 3 ): %f\n", getfloat((vec_float4)a_Vector4[3]) );
printf("Vector4::getW(): %f\n", getfloat(a_Vector4.getW( )) );
print( ( a_Vector4 + b_Vector4 ), "Vector4 + Vector4" );
print( ( a_Vector4 - b_Vector4 ), "Vector4 - Vector4" );
print( ( a_Vector4 * randfloat() ), "Vector4 * float" );
print( ( a_Vector4 / randfloat() ), "Vector4 / float" );
print( ( randfloat() * a_Vector4 ), "float * Vector4" );
print( ( -a_Vector4 ), "Vector4 negate" );
print( mulPerElem( a_Vector4, b_Vector4 ), "mulPerElem( Vector4, Vector4 )" );
print( divPerElem( a_Vector4, b_Vector4 ), "divPerElem( Vector4, Vector4 )" );
print( recipPerElem( a_Vector4 ), "Vector4 recip" );
print( sqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 sqrt" );
print( rsqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 rsqrt" );
print( absPerElem( a_Vector4 ), "Vector4 abs" );
print( copySignPerElem( a_Vector4, b_Vector4 ), "Vector4 copySign" );
print( maxPerElem( a_Vector4, b_Vector4 ), "Vector4 maximum Vector4" );
print( minPerElem( a_Vector4, b_Vector4 ), "Vector4 minimum Vector4" );
printf("Vector4 maximum of elements: %f\n", getfloat(maxElem( a_Vector4 )));
printf("Vector4 minimum of elements: %f\n", getfloat(minElem( a_Vector4 )));
printf("Vector4 sum of elements: %f\n", getfloat(sum( a_Vector4 )));
printf("Vector4 dot Vector4: %f\n", getfloat(dot( a_Vector4, b_Vector4 )));
printf("Vector4 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector4 )));
printf("Vector4 length: %f\n", getfloat(length( a_Vector4 )));
print( normalize( a_Vector4 ), "Vector4 normalized" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
e_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
b_Vector4 = normalize( b_Vector4 );
c_Vector4 = normalize( c_Vector4 );
d_Vector4 = normalize( d_Vector4 );
e_Vector4 = normalize( e_Vector4 );
a_Vector4 = lerp( randfloat(), b_Vector4, c_Vector4 );
print( a_Vector4, "Vector4 lerp" );
a_Vector4 = slerp( randfloat(), b_Vector4, c_Vector4 );
print( a_Vector4, "Vector4 slerp" );
}
void
Point3_methods_test()
{
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat;
Aos::Point3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3;
Point3 soa_Point3;
Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4;
float xyz4[12] __attribute__ ((aligned(16)));
xyz4[0] = getfloat(randfloat());
xyz4[1] = getfloat(randfloat());
xyz4[2] = getfloat(randfloat());
xyz4[3] = getfloat(randfloat());
xyz4[4] = getfloat(randfloat());
xyz4[5] = getfloat(randfloat());
xyz4[6] = getfloat(randfloat());
xyz4[7] = getfloat(randfloat());
xyz4[8] = getfloat(randfloat());
xyz4[9] = getfloat(randfloat());
xyz4[10] = getfloat(randfloat());
xyz4[11] = getfloat(randfloat());
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
c_Vector3 = Vector3( (vec_float4){0.0f} );
d_Vector3 = Vector3( (vec_float4){0.0f} );
e_Vector3 = Vector3( (vec_float4){0.0f} );
print( c_Vector3, "set Vector3 elements to zero" );
print( d_Vector3, "set Vector3 elements to zero" );
print( e_Vector3, "set Vector3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
c_Vector4 = Vector4( (vec_float4){0.0f} );
d_Vector4 = Vector4( (vec_float4){0.0f} );
e_Vector4 = Vector4( (vec_float4){0.0f} );
print( c_Vector4, "set Vector4 elements to zero" );
print( d_Vector4, "set Vector4 elements to zero" );
print( e_Vector4, "set Vector4 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
c_Point3 = Point3( (vec_float4){0.0f} );
d_Point3 = Point3( (vec_float4){0.0f} );
e_Point3 = Point3( (vec_float4){0.0f} );
print( c_Point3, "set Point3 elements to zero" );
print( d_Point3, "set Point3 elements to zero" );
print( e_Point3, "set Point3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
c_Quat = Quat( (vec_float4){0.0f} );
d_Quat = Quat( (vec_float4){0.0f} );
e_Quat = Quat( (vec_float4){0.0f} );
print( c_Quat, "set Quat elements to zero" );
print( d_Quat, "set Quat elements to zero" );
print( e_Quat, "set Quat elements to zero" );
a_Point3 = Point3( a_Vector3 );
print( a_Point3, "construct Point3 with Vector3" );
a_Point3 = Point3( randfloat() );
print( a_Point3, "set Point3 with float" );
a_Point3 = Point3( randfloat() );
print( a_Point3, "set Point3 with float" );
aos_Point3_0 = Aos::Point3( 0.0f, 1.0f, 2.0f );
aos_Point3_1 = Aos::Point3( 3.0f, 4.0f, 5.0f );
aos_Point3_2 = Aos::Point3( 6.0f, 7.0f, 8.0f );
aos_Point3_3 = Aos::Point3( 9.0f, 10.0f, 11.0f );
soa_Point3 = Point3( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 );
soa_Point3.get4Aos( aos_Point3_3, aos_Point3_2, aos_Point3_1, aos_Point3_0 );
Aos::print( aos_Point3_0, "aos type 0" );
Aos::print( aos_Point3_1, "aos type 1" );
Aos::print( aos_Point3_2, "aos type 2" );
Aos::print( aos_Point3_3, "aos type 3" );
a_Point3 = select( a_Point3, b_Point3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) );
a_Point3.get4Aos( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 );
Aos::print( aos_Point3_0, "select 0" );
Aos::print( aos_Point3_1, "select 1" );
Aos::print( aos_Point3_2, "select 2" );
Aos::print( aos_Point3_3, "select 3" );
loadXYZArray( a_Point3, (const vec_float4 *)xyz4 );
print( a_Point3, "load XYZ array" );
a_Point3 = Point3( ( -Vector3( a_Point3 ) ) );
storeXYZArray( a_Point3, (vec_float4 *)xyz4 );
aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] );
aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] );
aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] );
Aos::print( aos_Vector4_0, "xyzx" );
Aos::print( aos_Vector4_1, "yzxy" );
Aos::print( aos_Vector4_2, "zxyz" );
Aos::print( aos_Vector4_0, "xyzx" );
Aos::print( aos_Vector4_1, "yzxy" );
Aos::print( aos_Vector4_2, "zxyz" );
printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n");
a_Point3 = b_Point3;
print( a_Point3, "assign to Point3 from Point3" );
a_Point3 = Point3( (vec_float4){0.0f} );
print( a_Point3, "set Point3 elements to zero" );
a_Point3.setElem( 0, randfloat() );
print( a_Point3, "Point3::set( 0, float )" );
a_Point3[0] = randfloat();
a_Point3[0] = vec_mul_float( a_Point3[0], randfloat() );
a_Point3[0] = divf4( a_Point3[0], randfloat() );
a_Point3[0] = vec_add_float( a_Point3[0], randfloat() );
a_Point3[0] = vec_sub_float( a_Point3[0], randfloat() );
print( a_Point3, "Point3::operator [](0)" );
a_Point3.setX( randfloat() );
print( a_Point3, "Point3::setX()" );
a_Point3.setElem( 1, randfloat() );
print( a_Point3, "Point3::set( 1, float )" );
a_Point3[1] = randfloat();
a_Point3[1] = vec_mul_float( a_Point3[1], randfloat() );
a_Point3[1] = divf4( a_Point3[1], randfloat() );
a_Point3[1] = vec_add_float( a_Point3[1], randfloat() );
a_Point3[1] = vec_sub_float( a_Point3[1], randfloat() );
print( a_Point3, "Point3::operator [](1)" );
a_Point3.setY( randfloat() );
print( a_Point3, "Point3::setY()" );
a_Point3.setElem( 2, randfloat() );
print( a_Point3, "Point3::set( 2, float )" );
a_Point3[2] = randfloat();
a_Point3[2] = vec_mul_float( a_Point3[2], randfloat() );
a_Point3[2] = divf4( a_Point3[2], randfloat() );
a_Point3[2] = vec_add_float( a_Point3[2], randfloat() );
a_Point3[2] = vec_sub_float( a_Point3[2], randfloat() );
print( a_Point3, "Point3::operator [](2)" );
a_Point3.setZ( randfloat() );
print( a_Point3, "Point3::setZ()" );
printf("Point3::get( 0 ): %f\n", getfloat(a_Point3.getElem( 0 )) );
printf("Point3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Point3[0]) );
printf("Point3::getX(): %f\n", getfloat(a_Point3.getX( )) );
printf("Point3::get( 1 ): %f\n", getfloat(a_Point3.getElem( 1 )) );
printf("Point3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Point3[1]) );
printf("Point3::getY(): %f\n", getfloat(a_Point3.getY( )) );
printf("Point3::get( 2 ): %f\n", getfloat(a_Point3.getElem( 2 )) );
printf("Point3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Point3[2]) );
printf("Point3::getZ(): %f\n", getfloat(a_Point3.getZ( )) );
print( ( a_Point3 - b_Point3 ), "Point3 - Point3" );
print( ( a_Point3 + b_Vector3 ), "Point3 + Vector3" );
print( ( a_Point3 - b_Vector3 ), "Point3 - Vector3" );
print( mulPerElem( a_Point3, b_Point3 ), "mulPerElem( Point3, Point3 )" );
print( divPerElem( a_Point3, b_Point3 ), "divPerElem( Point3, Point3 )" );
print( recipPerElem( a_Point3 ), "Point3 recip" );
print( sqrtPerElem( absPerElem( a_Point3 ) ), "Point3 sqrt" );
print( rsqrtPerElem( absPerElem( a_Point3 ) ), "Point3 rsqrt" );
print( absPerElem( a_Point3 ), "Point3 abs" );
print( copySignPerElem( a_Point3, b_Point3 ), "Point3 copySign" );
print( maxPerElem( a_Point3, b_Point3 ), "Point3 maximum Point3" );
print( minPerElem( a_Point3, b_Point3 ), "Point3 minimum Point3" );
printf("Point3 maximum of elements: %f\n", getfloat(maxElem( a_Point3 )));
printf("Point3 minimum of elements: %f\n", getfloat(minElem( a_Point3 )));
printf("Point3 sum of elements: %f\n", getfloat(sum( a_Point3 )));
printf("Point projection: %f\n", getfloat(projection( a_Point3, b_Vector3 )));
printf("Point distSqrFromOrigin: %f\n", getfloat(distSqrFromOrigin( a_Point3 )) );
printf("Point distFromOrigin: %f\n", getfloat(distFromOrigin( a_Point3 )) );
printf("Point distSqr: %f\n", getfloat(distSqr( a_Point3, b_Point3 )) );
printf("Point dist: %f\n", getfloat(dist( a_Point3, b_Point3 )) );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
e_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
a_Point3 = lerp( randfloat(), b_Point3, c_Point3 );
print( a_Point3, "Point3 lerp" );
}
void
Quat_methods_test()
{
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat;
Aos::Quat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3;
Quat soa_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
c_Vector3 = Vector3( (vec_float4){0.0f} );
d_Vector3 = Vector3( (vec_float4){0.0f} );
e_Vector3 = Vector3( (vec_float4){0.0f} );
print( c_Vector3, "set Vector3 elements to zero" );
print( d_Vector3, "set Vector3 elements to zero" );
print( e_Vector3, "set Vector3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
c_Vector4 = Vector4( (vec_float4){0.0f} );
d_Vector4 = Vector4( (vec_float4){0.0f} );
e_Vector4 = Vector4( (vec_float4){0.0f} );
print( c_Vector4, "set Vector4 elements to zero" );
print( d_Vector4, "set Vector4 elements to zero" );
print( e_Vector4, "set Vector4 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
b_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
c_Point3 = Point3( (vec_float4){0.0f} );
d_Point3 = Point3( (vec_float4){0.0f} );
e_Point3 = Point3( (vec_float4){0.0f} );
print( c_Point3, "set Point3 elements to zero" );
print( d_Point3, "set Point3 elements to zero" );
print( e_Point3, "set Point3 elements to zero" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
c_Quat = Quat( (vec_float4){0.0f} );
d_Quat = Quat( (vec_float4){0.0f} );
e_Quat = Quat( (vec_float4){0.0f} );
print( c_Quat, "set Quat elements to zero" );
print( d_Quat, "set Quat elements to zero" );
print( e_Quat, "set Quat elements to zero" );
a_Quat = Quat( a_Vector3, randfloat() );
print( a_Quat, "set Quat with Vector3, float" );
a_Quat = Quat( a_Vector4 );
print( a_Quat, "construct Quat with Vector4" );
a_Quat = Quat( randfloat() );
print( a_Quat, "set Quat with float" );
a_Quat = Quat( randfloat() );
print( a_Quat, "set Quat with float" );
aos_Quat_0 = Aos::Quat( 0.0f, 1.0f, 2.0f, 3.0f );
aos_Quat_1 = Aos::Quat( 4.0f, 5.0f, 6.0f, 7.0f );
aos_Quat_2 = Aos::Quat( 8.0f, 9.0f, 10.0f, 11.0f );
aos_Quat_3 = Aos::Quat( 12.0f, 13.0f, 14.0f, 15.0f );
soa_Quat = Quat( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 );
soa_Quat.get4Aos( aos_Quat_3, aos_Quat_2, aos_Quat_1, aos_Quat_0 );
Aos::print( aos_Quat_0, "aos type 0" );
Aos::print( aos_Quat_1, "aos type 1" );
Aos::print( aos_Quat_2, "aos type 2" );
Aos::print( aos_Quat_3, "aos type 3" );
a_Quat = select( a_Quat, b_Quat, ((vec_uint4){0,0xffffffff,0,0xffffffff}) );
a_Quat.get4Aos( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 );
Aos::print( aos_Quat_0, "select 0" );
Aos::print( aos_Quat_1, "select 1" );
Aos::print( aos_Quat_2, "select 2" );
Aos::print( aos_Quat_3, "select 3" );
a_Quat = b_Quat;
print( a_Quat, "assign to Quat from Quat" );
a_Quat.setXYZ( a_Vector3 );
print( a_Quat, "set Quat xyz" );
print( a_Quat.getXYZ( ), "get Quat xyz" );
a_Quat = Quat( (vec_float4){0.0f} );
print( a_Quat, "set Quat elements to zero" );
a_Quat.setElem( 0, randfloat() );
print( a_Quat, "Quat::set( 0, float )" );
a_Quat[0] = randfloat();
a_Quat[0] = vec_mul_float( a_Quat[0], randfloat() );
a_Quat[0] = divf4( a_Quat[0], randfloat() );
a_Quat[0] = vec_add_float( a_Quat[0], randfloat() );
a_Quat[0] = vec_sub_float( a_Quat[0], randfloat() );
print( a_Quat, "Quat::operator [](0)" );
a_Quat.setX( randfloat() );
print( a_Quat, "Quat::setX()" );
a_Quat.setElem( 1, randfloat() );
print( a_Quat, "Quat::set( 1, float )" );
a_Quat[1] = randfloat();
a_Quat[1] = vec_mul_float( a_Quat[1], randfloat() );
a_Quat[1] = divf4( a_Quat[1], randfloat() );
a_Quat[1] = vec_add_float( a_Quat[1], randfloat() );
a_Quat[1] = vec_sub_float( a_Quat[1], randfloat() );
print( a_Quat, "Quat::operator [](1)" );
a_Quat.setY( randfloat() );
print( a_Quat, "Quat::setY()" );
a_Quat.setElem( 2, randfloat() );
print( a_Quat, "Quat::set( 2, float )" );
a_Quat[2] = randfloat();
a_Quat[2] = vec_mul_float( a_Quat[2], randfloat() );
a_Quat[2] = divf4( a_Quat[2], randfloat() );
a_Quat[2] = vec_add_float( a_Quat[2], randfloat() );
a_Quat[2] = vec_sub_float( a_Quat[2], randfloat() );
print( a_Quat, "Quat::operator [](2)" );
a_Quat.setZ( randfloat() );
print( a_Quat, "Quat::setZ()" );
a_Quat.setElem( 3, randfloat() );
print( a_Quat, "Quat::set( 3, float )" );
a_Quat[3] = randfloat();
a_Quat[3] = vec_mul_float( a_Quat[3], randfloat() );
a_Quat[3] = divf4( a_Quat[3], randfloat() );
a_Quat[3] = vec_add_float( a_Quat[3], randfloat() );
a_Quat[3] = vec_sub_float( a_Quat[3], randfloat() );
print( a_Quat, "Quat::operator [](3)" );
a_Quat.setW( randfloat() );
print( a_Quat, "Quat::setW()" );
printf("Quat::get( 0 ): %f\n", getfloat(a_Quat.getElem( 0 )) );
printf("Quat::operator []( 0 ): %f\n", getfloat((vec_float4)a_Quat[0]) );
printf("Quat::getX(): %f\n", getfloat(a_Quat.getX( )) );
printf("Quat::get( 1 ): %f\n", getfloat(a_Quat.getElem( 1 )) );
printf("Quat::operator []( 1 ): %f\n", getfloat((vec_float4)a_Quat[1]) );
printf("Quat::getY(): %f\n", getfloat(a_Quat.getY( )) );
printf("Quat::get( 2 ): %f\n", getfloat(a_Quat.getElem( 2 )) );
printf("Quat::operator []( 2 ): %f\n", getfloat((vec_float4)a_Quat[2]) );
printf("Quat::getZ(): %f\n", getfloat(a_Quat.getZ( )) );
printf("Quat::get( 3 ): %f\n", getfloat(a_Quat.getElem( 3 )) );
printf("Quat::operator []( 3 ): %f\n", getfloat((vec_float4)a_Quat[3]) );
printf("Quat::getW(): %f\n", getfloat(a_Quat.getW( )) );
print( ( a_Quat + b_Quat ), "Quat + Quat" );
print( ( a_Quat - b_Quat ), "Quat - Quat" );
print( ( a_Quat * b_Quat ), "Quat * Quat" );
print( ( a_Quat * randfloat() ), "Quat * float" );
print( ( a_Quat / randfloat() ), "Quat / float" );
print( ( randfloat() * a_Quat ), "float * Quat" );
print( ( -a_Quat ), "Quat negate" );
printf("Quat dot Quat: %f\n", getfloat(dot( a_Quat, b_Quat )));
printf("Quat lengthSqr: %f\n", getfloat(norm( a_Quat )));
printf("Quat length: %f\n", getfloat(length( a_Quat )));
print( normalize( a_Quat ), "Quat normalized" );
a_Quat = Quat::identity( );
print( a_Quat, "set to identity" );
a_Quat = Quat::rotation( a_Vector3, b_Vector3 );
print( a_Quat, "Quat rotation between vectors" );
a_Quat = Quat::rotation( randfloat(), a_Vector3 );
print( a_Quat, "Quat rotation axis angle" );
a_Quat = Quat::rotationX( randfloat() );
print( a_Quat, "Quat rotationX" );
a_Quat = Quat::rotationY( randfloat() );
print( a_Quat, "Quat rotationY" );
a_Quat = Quat::rotationZ( randfloat() );
print( a_Quat, "Quat rotationZ" );
print( rotate( a_Quat, a_Vector3 ), "Quat rotate Vector3" );
print( conj( a_Quat ), "Quat conj" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
e_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
b_Quat = normalize( b_Quat );
c_Quat = normalize( c_Quat );
d_Quat = normalize( d_Quat );
e_Quat = normalize( e_Quat );
a_Quat = lerp( randfloat(), b_Quat, c_Quat );
print( a_Quat, "Quat lerp" );
a_Quat = slerp( randfloat(), b_Quat, c_Quat );
print( a_Quat, "Quat slerp" );
a_Quat = squad( randfloat(), b_Quat, c_Quat, d_Quat, e_Quat );
print( a_Quat, "Quat squad" );
}
int main()
{
printf("\n __begin__ \n");
for ( iteration = 0; iteration < 2; iteration++ ) {
Vector3_methods_test();
Vector4_methods_test();
Point3_methods_test();
Quat_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,852 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7;
VmathQuat tmpQ_0;
VmathVector3 tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathQNormalize( &tmpQ_0, &a_Quat );
vmathM3MakeFromQ( &a_Matrix3, &tmpQ_0 );
vmathM3Prints( &a_Matrix3, "construct Matrix3 with Quat" );
vmathQMakeFromM3( &a_Quat, &a_Matrix3 );
vmathQPrints( &a_Quat, "construct Quat with Matrix3" );
vmathM3Copy( &a_Matrix3, &b_Matrix3 );
vmathM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" );
vmathM3MakeFromScalar( &a_Matrix3, randfloat() );
vmathM3Prints( &a_Matrix3, "set Matrix3 with float" );
vmathM3MakeFromScalar( &a_Matrix3, randfloat() );
vmathM3Prints( &a_Matrix3, "set Matrix3 with float" );
vmathM3MakeFromScalar( &a_Matrix3, 0.0f );
vmathM3Prints( &a_Matrix3, "set elements to zero" );
vmathM3MakeIdentity( &a_Matrix3 );
vmathM3Prints( &a_Matrix3, "set to identity" );
vmathM3MakeRotationX( &a_Matrix3, randfloat() );
vmathM3Prints( &a_Matrix3, "set to rotationX" );
vmathM3MakeRotationY( &a_Matrix3, randfloat() );
vmathM3Prints( &a_Matrix3, "set to rotationY" );
vmathM3MakeRotationZ( &a_Matrix3, randfloat() );
vmathM3Prints( &a_Matrix3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 );
vmathM3MakeRotationZYX( &a_Matrix3, &tmpV3_8 );
vmathM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" );
vmathV3Normalize( &tmpV3_9, &a_Vector3 );
vmathM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_9 );
vmathM3Prints( &a_Matrix3, "set to rotation from axis angle" );
vmathM3SetCol0( &a_Matrix3, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" );
vmathM3SetCol1( &a_Matrix3, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" );
vmathM3SetCol2( &a_Matrix3, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" );
vmathM3GetCol0( &tmpV3_10, &a_Matrix3 );
vmathV3Prints( &tmpV3_10, "Matrix3 get col 0" );
vmathM3GetCol1( &tmpV3_11, &a_Matrix3 );
vmathV3Prints( &tmpV3_11, "Matrix3 get col 1" );
vmathM3GetCol2( &tmpV3_12, &a_Matrix3 );
vmathV3Prints( &tmpV3_12, "Matrix3 get col 2" );
vmathM3SetCol( &a_Matrix3, 0, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" );
vmathM3SetCol( &a_Matrix3, 1, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" );
vmathM3SetCol( &a_Matrix3, 2, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" );
vmathM3GetCol( &tmpV3_13, &a_Matrix3, 0 );
vmathV3Prints( &tmpV3_13, "Matrix3 get col 0" );
vmathM3GetCol( &tmpV3_14, &a_Matrix3, 1 );
vmathV3Prints( &tmpV3_14, "Matrix3 get col 1" );
vmathM3GetCol( &tmpV3_15, &a_Matrix3, 2 );
vmathV3Prints( &tmpV3_15, "Matrix3 get col 2" );
vmathM3SetRow( &a_Matrix3, 0, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set row 0" );
vmathM3SetRow( &a_Matrix3, 1, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set row 1" );
vmathM3SetRow( &a_Matrix3, 2, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "Matrix3 set row 2" );
vmathM3GetRow( &tmpV3_16, &a_Matrix3, 0 );
vmathV3Prints( &tmpV3_16, "Matrix3 get row 0" );
vmathM3GetRow( &tmpV3_17, &a_Matrix3, 1 );
vmathV3Prints( &tmpV3_17, "Matrix3 get row 1" );
vmathM3GetRow( &tmpV3_18, &a_Matrix3, 2 );
vmathV3Prints( &tmpV3_18, "Matrix3 get row 2" );
vmathM3SetCol( &a_Matrix3, 0, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "set " );
vmathM3SetCol( &a_Matrix3, 1, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "set " );
vmathM3SetCol( &a_Matrix3, 2, &a_Vector3 );
vmathM3Prints( &a_Matrix3, "set " );
vmathM3GetCol( &tmpV3_19, &a_Matrix3, 0 );
vmathV3Prints( &tmpV3_19, "get " );
vmathM3GetCol( &tmpV3_20, &a_Matrix3, 1 );
vmathV3Prints( &tmpV3_20, "get " );
vmathM3GetCol( &tmpV3_21, &a_Matrix3, 2 );
vmathV3Prints( &tmpV3_21, "get " );
vmathM3SetElem( &a_Matrix3, 0, 0, randfloat() );
vmathM3SetElem( &a_Matrix3, 0, 1, randfloat() );
vmathM3SetElem( &a_Matrix3, 0, 2, randfloat() );
vmathM3SetElem( &a_Matrix3, 1, 0, randfloat() );
vmathM3SetElem( &a_Matrix3, 1, 1, randfloat() );
vmathM3SetElem( &a_Matrix3, 1, 2, randfloat() );
vmathM3SetElem( &a_Matrix3, 2, 0, randfloat() );
vmathM3SetElem( &a_Matrix3, 2, 1, randfloat() );
vmathM3SetElem( &a_Matrix3, 2, 2, randfloat() );
vmathM3Prints( &a_Matrix3, "Matrix3 set elements" );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 0 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 1 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 2 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 0 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 1 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 2 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 0 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 1 )) );
printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 2 )) );
}
void
Matrix4_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9;
VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathM4MakeFromT3( &a_Matrix4, &a_Transform3 );
vmathM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" );
vmathM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 );
vmathM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" );
vmathM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 );
vmathM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" );
vmathM4Copy( &a_Matrix4, &b_Matrix4 );
vmathM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" );
vmathM4MakeFromScalar( &a_Matrix4, randfloat() );
vmathM4Prints( &a_Matrix4, "set Matrix4 with float" );
vmathM4MakeFromScalar( &a_Matrix4, randfloat() );
vmathM4Prints( &a_Matrix4, "set Matrix4 with float" );
vmathM4MakeFromScalar( &a_Matrix4, 0.0f );
vmathM4Prints( &a_Matrix4, "set elements to zero" );
vmathM4MakeIdentity( &a_Matrix4 );
vmathM4Prints( &a_Matrix4, "set to identity" );
vmathM4MakeRotationX( &a_Matrix4, randfloat() );
vmathM4Prints( &a_Matrix4, "set to rotationX" );
vmathM4MakeRotationY( &a_Matrix4, randfloat() );
vmathM4Prints( &a_Matrix4, "set to rotationY" );
vmathM4MakeRotationZ( &a_Matrix4, randfloat() );
vmathM4Prints( &a_Matrix4, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 );
vmathM4MakeRotationZYX( &a_Matrix4, &tmpV3_8 );
vmathM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" );
vmathV3Normalize( &tmpV3_9, &a_Vector3 );
vmathM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_9 );
vmathM4Prints( &a_Matrix4, "set to rotation from axis angle" );
vmathM4MakeTranslation( &a_Matrix4, &a_Vector3 );
vmathM4Prints( &a_Matrix4, "set to translation" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathM4Prints( &a_Matrix4, "set to perspective matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
vmathM4Prints( &a_Matrix4, "set to frustum matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
vmathM4Prints( &a_Matrix4, "set to orthographic matrix" );
vmathM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 );
vmathM4Prints( &a_Matrix4, "set to look-at matrix" );
vmathM4SetCol0( &a_Matrix4, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" );
vmathM4SetCol1( &a_Matrix4, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" );
vmathM4SetCol2( &a_Matrix4, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" );
vmathM4SetCol3( &a_Matrix4, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" );
vmathM4GetCol0( &tmpV4_0, &a_Matrix4 );
vmathV4Prints( &tmpV4_0, "Matrix4 get col 0" );
vmathM4GetCol1( &tmpV4_1, &a_Matrix4 );
vmathV4Prints( &tmpV4_1, "Matrix4 get col 1" );
vmathM4GetCol2( &tmpV4_2, &a_Matrix4 );
vmathV4Prints( &tmpV4_2, "Matrix4 get col 2" );
vmathM4GetCol3( &tmpV4_3, &a_Matrix4 );
vmathV4Prints( &tmpV4_3, "Matrix4 get col 3" );
vmathM4SetCol( &a_Matrix4, 0, &b_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" );
vmathM4SetCol( &a_Matrix4, 1, &b_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" );
vmathM4SetCol( &a_Matrix4, 2, &b_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" );
vmathM4SetCol( &a_Matrix4, 3, &b_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" );
vmathM4GetCol( &tmpV4_4, &a_Matrix4, 0 );
vmathV4Prints( &tmpV4_4, "Matrix4 get col 0" );
vmathM4GetCol( &tmpV4_5, &a_Matrix4, 1 );
vmathV4Prints( &tmpV4_5, "Matrix4 get col 1" );
vmathM4GetCol( &tmpV4_6, &a_Matrix4, 2 );
vmathV4Prints( &tmpV4_6, "Matrix4 get col 2" );
vmathM4GetCol( &tmpV4_7, &a_Matrix4, 3 );
vmathV4Prints( &tmpV4_7, "Matrix4 get col 3" );
vmathM4SetRow( &a_Matrix4, 0, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set row 0" );
vmathM4SetRow( &a_Matrix4, 1, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set row 1" );
vmathM4SetRow( &a_Matrix4, 2, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set row 2" );
vmathM4SetRow( &a_Matrix4, 3, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "Matrix4 set row 3" );
vmathM4GetRow( &tmpV4_8, &a_Matrix4, 0 );
vmathV4Prints( &tmpV4_8, "Matrix4 get row 0" );
vmathM4GetRow( &tmpV4_9, &a_Matrix4, 1 );
vmathV4Prints( &tmpV4_9, "Matrix4 get row 1" );
vmathM4GetRow( &tmpV4_10, &a_Matrix4, 2 );
vmathV4Prints( &tmpV4_10, "Matrix4 get row 2" );
vmathM4GetRow( &tmpV4_11, &a_Matrix4, 3 );
vmathV4Prints( &tmpV4_11, "Matrix4 get row 3" );
vmathM4SetCol( &a_Matrix4, 0, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "set " );
vmathM4SetCol( &a_Matrix4, 1, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "set " );
vmathM4SetCol( &a_Matrix4, 2, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "set " );
vmathM4SetCol( &a_Matrix4, 3, &a_Vector4 );
vmathM4Prints( &a_Matrix4, "set " );
vmathM4GetCol( &tmpV4_12, &a_Matrix4, 0 );
vmathV4Prints( &tmpV4_12, "get " );
vmathM4GetCol( &tmpV4_13, &a_Matrix4, 1 );
vmathV4Prints( &tmpV4_13, "get " );
vmathM4GetCol( &tmpV4_14, &a_Matrix4, 2 );
vmathV4Prints( &tmpV4_14, "get " );
vmathM4GetCol( &tmpV4_15, &a_Matrix4, 3 );
vmathV4Prints( &tmpV4_15, "get " );
vmathM4SetElem( &a_Matrix4, 0, 0, randfloat() );
vmathM4SetElem( &a_Matrix4, 0, 1, randfloat() );
vmathM4SetElem( &a_Matrix4, 0, 2, randfloat() );
vmathM4SetElem( &a_Matrix4, 0, 3, randfloat() );
vmathM4SetElem( &a_Matrix4, 1, 0, randfloat() );
vmathM4SetElem( &a_Matrix4, 1, 1, randfloat() );
vmathM4SetElem( &a_Matrix4, 1, 2, randfloat() );
vmathM4SetElem( &a_Matrix4, 1, 3, randfloat() );
vmathM4SetElem( &a_Matrix4, 2, 0, randfloat() );
vmathM4SetElem( &a_Matrix4, 2, 1, randfloat() );
vmathM4SetElem( &a_Matrix4, 2, 2, randfloat() );
vmathM4SetElem( &a_Matrix4, 2, 3, randfloat() );
vmathM4SetElem( &a_Matrix4, 3, 0, randfloat() );
vmathM4SetElem( &a_Matrix4, 3, 1, randfloat() );
vmathM4SetElem( &a_Matrix4, 3, 2, randfloat() );
vmathM4SetElem( &a_Matrix4, 3, 3, randfloat() );
vmathM4Prints( &a_Matrix4, "Matrix4 set elements" );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 0 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 1 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 2 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 3 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 0 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 1 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 2 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 3 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 0 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 1 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 2 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 3 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 0 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 1 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 2 )) );
printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 3 )) );
}
void
Transform3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17;
VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2;
VmathVector3 tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" );
vmathT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 );
vmathT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" );
vmathT3Copy( &a_Transform3, &b_Transform3 );
vmathT3Prints( &a_Transform3, "assign to Transform3 from Transform3" );
vmathT3MakeFromScalar( &a_Transform3, randfloat() );
vmathT3Prints( &a_Transform3, "set Transform3 with float" );
vmathT3MakeFromScalar( &a_Transform3, randfloat() );
vmathT3Prints( &a_Transform3, "set Transform3 with float" );
vmathT3MakeFromScalar( &a_Transform3, 0.0f );
vmathT3Prints( &a_Transform3, "set elements to zero" );
vmathT3MakeIdentity( &a_Transform3 );
vmathT3Prints( &a_Transform3, "set to identity" );
vmathT3MakeRotationX( &a_Transform3, randfloat() );
vmathT3Prints( &a_Transform3, "set to rotationX" );
vmathT3MakeRotationY( &a_Transform3, randfloat() );
vmathT3Prints( &a_Transform3, "set to rotationY" );
vmathT3MakeRotationZ( &a_Transform3, randfloat() );
vmathT3Prints( &a_Transform3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 );
vmathT3MakeRotationZYX( &a_Transform3, &tmpV3_8 );
vmathT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" );
vmathV3Normalize( &tmpV3_9, &a_Vector3 );
vmathT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_9 );
vmathT3Prints( &a_Transform3, "set to rotation from axis angle" );
vmathT3MakeTranslation( &a_Transform3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "set to translation" );
vmathT3SetCol0( &a_Transform3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 0" );
vmathT3SetCol1( &a_Transform3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 1" );
vmathT3SetCol2( &a_Transform3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 2" );
vmathT3SetCol3( &a_Transform3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 3" );
vmathT3GetCol0( &tmpV3_10, &a_Transform3 );
vmathV3Prints( &tmpV3_10, "Transform3 get col 0" );
vmathT3GetCol1( &tmpV3_11, &a_Transform3 );
vmathV3Prints( &tmpV3_11, "Transform3 get col 1" );
vmathT3GetCol2( &tmpV3_12, &a_Transform3 );
vmathV3Prints( &tmpV3_12, "Transform3 get col 2" );
vmathT3GetCol3( &tmpV3_13, &a_Transform3 );
vmathV3Prints( &tmpV3_13, "Transform3 get col 3" );
vmathT3SetCol( &a_Transform3, 0, &b_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 0" );
vmathT3SetCol( &a_Transform3, 1, &b_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 1" );
vmathT3SetCol( &a_Transform3, 2, &b_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 2" );
vmathT3SetCol( &a_Transform3, 3, &b_Vector3 );
vmathT3Prints( &a_Transform3, "Transform3 set col 3" );
vmathT3GetCol( &tmpV3_14, &a_Transform3, 0 );
vmathV3Prints( &tmpV3_14, "Transform3 get col 0" );
vmathT3GetCol( &tmpV3_15, &a_Transform3, 1 );
vmathV3Prints( &tmpV3_15, "Transform3 get col 1" );
vmathT3GetCol( &tmpV3_16, &a_Transform3, 2 );
vmathV3Prints( &tmpV3_16, "Transform3 get col 2" );
vmathT3GetCol( &tmpV3_17, &a_Transform3, 3 );
vmathV3Prints( &tmpV3_17, "Transform3 get col 3" );
vmathT3SetRow( &a_Transform3, 0, &a_Vector4 );
vmathT3Prints( &a_Transform3, "Transform3 set row 0" );
vmathT3SetRow( &a_Transform3, 1, &a_Vector4 );
vmathT3Prints( &a_Transform3, "Transform3 set row 1" );
vmathT3SetRow( &a_Transform3, 2, &a_Vector4 );
vmathT3Prints( &a_Transform3, "Transform3 set row 2" );
vmathT3GetRow( &tmpV4_0, &a_Transform3, 0 );
vmathV4Prints( &tmpV4_0, "Transform3 get row 0" );
vmathT3GetRow( &tmpV4_1, &a_Transform3, 1 );
vmathV4Prints( &tmpV4_1, "Transform3 get row 1" );
vmathT3GetRow( &tmpV4_2, &a_Transform3, 2 );
vmathV4Prints( &tmpV4_2, "Transform3 get row 2" );
vmathT3SetCol( &a_Transform3, 0, &a_Vector3 );
vmathT3Prints( &a_Transform3, "set " );
vmathT3SetCol( &a_Transform3, 1, &a_Vector3 );
vmathT3Prints( &a_Transform3, "set " );
vmathT3SetCol( &a_Transform3, 2, &a_Vector3 );
vmathT3Prints( &a_Transform3, "set " );
vmathT3SetCol( &a_Transform3, 3, &a_Vector3 );
vmathT3Prints( &a_Transform3, "set " );
vmathT3GetCol( &tmpV3_18, &a_Transform3, 0 );
vmathV3Prints( &tmpV3_18, "get " );
vmathT3GetCol( &tmpV3_19, &a_Transform3, 1 );
vmathV3Prints( &tmpV3_19, "get " );
vmathT3GetCol( &tmpV3_20, &a_Transform3, 2 );
vmathV3Prints( &tmpV3_20, "get " );
vmathT3GetCol( &tmpV3_21, &a_Transform3, 3 );
vmathV3Prints( &tmpV3_21, "get " );
vmathT3SetElem( &a_Transform3, 0, 0, randfloat() );
vmathT3SetElem( &a_Transform3, 0, 1, randfloat() );
vmathT3SetElem( &a_Transform3, 0, 2, randfloat() );
vmathT3SetElem( &a_Transform3, 1, 0, randfloat() );
vmathT3SetElem( &a_Transform3, 1, 1, randfloat() );
vmathT3SetElem( &a_Transform3, 1, 2, randfloat() );
vmathT3SetElem( &a_Transform3, 2, 0, randfloat() );
vmathT3SetElem( &a_Transform3, 2, 1, randfloat() );
vmathT3SetElem( &a_Transform3, 2, 2, randfloat() );
vmathT3SetElem( &a_Transform3, 3, 0, randfloat() );
vmathT3SetElem( &a_Transform3, 3, 1, randfloat() );
vmathT3SetElem( &a_Transform3, 3, 2, randfloat() );
vmathT3Prints( &a_Transform3, "Transform3 set elements" );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 0 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 1 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 2 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 0 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 1 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 2 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 0 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 1 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 2 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 0 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 1 )) );
printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 2 )) );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,784 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Aos;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Matrix3 = Matrix3( normalize( a_Quat ) );
print( a_Matrix3, "construct Matrix3 with Quat" );
a_Quat = Quat( a_Matrix3 );
print( a_Quat, "construct Quat with Matrix3" );
a_Matrix3 = b_Matrix3;
print( a_Matrix3, "assign to Matrix3 from Matrix3" );
a_Matrix3 = Matrix3( randfloat() );
print( a_Matrix3, "set Matrix3 with float" );
a_Matrix3 = Matrix3( scalar_float(randfloat()) );
print( a_Matrix3, "set Matrix3 with float" );
a_Matrix3 = Matrix3( 0.0f );
print( a_Matrix3, "set elements to zero" );
a_Matrix3 = Matrix3::identity( );
print( a_Matrix3, "set to identity" );
a_Matrix3 = Matrix3::rotationX( randfloat() );
print( a_Matrix3, "set to rotationX" );
a_Matrix3 = Matrix3::rotationY( randfloat() );
print( a_Matrix3, "set to rotationY" );
a_Matrix3 = Matrix3::rotationZ( randfloat() );
print( a_Matrix3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Matrix3, "set to rotation from Z,Y,X angles" );
a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Matrix3, "set to rotation from axis angle" );
a_Matrix3.setCol0( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 0" );
a_Matrix3.setCol1( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 1" );
a_Matrix3.setCol2( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 2" );
print( a_Matrix3.getCol0( ), "Matrix3 get col 0" );
print( a_Matrix3.getCol1( ), "Matrix3 get col 1" );
print( a_Matrix3.getCol2( ), "Matrix3 get col 2" );
a_Matrix3.setCol( 0, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 0" );
a_Matrix3.setCol( 1, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 1" );
a_Matrix3.setCol( 2, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 2" );
print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" );
print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" );
print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" );
a_Matrix3.setRow( 0, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 0" );
a_Matrix3.setRow( 1, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 1" );
a_Matrix3.setRow( 2, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 2" );
print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" );
print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" );
print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" );
a_Matrix3[0] = a_Vector3;
print( a_Matrix3, "set Matrix3[0]" );
a_Matrix3[1] = a_Vector3;
print( a_Matrix3, "set Matrix3[1]" );
a_Matrix3[2] = a_Vector3;
print( a_Matrix3, "set Matrix3[2]" );
a_Matrix3[0] = a_Vector3;
print( a_Matrix3[0], "get Matrix3[0]" );
a_Matrix3[1] = a_Vector3;
print( a_Matrix3[1], "get Matrix3[1]" );
a_Matrix3[2] = a_Vector3;
print( a_Matrix3[2], "get Matrix3[2]" );
a_Matrix3.setElem( 0, 0, randfloat() );
a_Matrix3.setElem( 0, 1, randfloat() );
a_Matrix3.setElem( 0, 2, randfloat() );
a_Matrix3.setElem( 1, 0, randfloat() );
a_Matrix3.setElem( 1, 1, randfloat() );
a_Matrix3.setElem( 1, 2, randfloat() );
a_Matrix3.setElem( 2, 0, randfloat() );
a_Matrix3.setElem( 2, 1, randfloat() );
a_Matrix3.setElem( 2, 2, randfloat() );
print( a_Matrix3, "Matrix3 set elements" );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Matrix4 = Matrix4( a_Transform3 );
print( a_Matrix4, "construct Matrix4 with Transform3" );
a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 );
print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" );
a_Matrix4 = Matrix4( a_Quat, a_Vector3 );
print( a_Matrix4, "construct Matrix4 with Quat and Vector3" );
a_Matrix4 = b_Matrix4;
print( a_Matrix4, "assign to Matrix4 from Matrix4" );
a_Matrix4 = Matrix4( randfloat() );
print( a_Matrix4, "set Matrix4 with float" );
a_Matrix4 = Matrix4( scalar_float(randfloat()) );
print( a_Matrix4, "set Matrix4 with float" );
a_Matrix4 = Matrix4( 0.0f );
print( a_Matrix4, "set elements to zero" );
a_Matrix4 = Matrix4::identity( );
print( a_Matrix4, "set to identity" );
a_Matrix4 = Matrix4::rotationX( randfloat() );
print( a_Matrix4, "set to rotationX" );
a_Matrix4 = Matrix4::rotationY( randfloat() );
print( a_Matrix4, "set to rotationY" );
a_Matrix4 = Matrix4::rotationZ( randfloat() );
print( a_Matrix4, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Matrix4, "set to rotation from Z,Y,X angles" );
a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Matrix4, "set to rotation from axis angle" );
a_Matrix4 = Matrix4::translation( a_Vector3 );
print( a_Matrix4, "set to translation" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Matrix4, "set to perspective matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
print( a_Matrix4, "set to frustum matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
print( a_Matrix4, "set to orthographic matrix" );
a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 );
print( a_Matrix4, "set to look-at matrix" );
a_Matrix4.setCol0( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 0" );
a_Matrix4.setCol1( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 1" );
a_Matrix4.setCol2( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 2" );
a_Matrix4.setCol3( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 3" );
print( a_Matrix4.getCol0( ), "Matrix4 get col 0" );
print( a_Matrix4.getCol1( ), "Matrix4 get col 1" );
print( a_Matrix4.getCol2( ), "Matrix4 get col 2" );
print( a_Matrix4.getCol3( ), "Matrix4 get col 3" );
a_Matrix4.setCol( 0, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 0" );
a_Matrix4.setCol( 1, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 1" );
a_Matrix4.setCol( 2, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 2" );
a_Matrix4.setCol( 3, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 3" );
print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" );
print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" );
print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" );
print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" );
a_Matrix4.setRow( 0, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 0" );
a_Matrix4.setRow( 1, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 1" );
a_Matrix4.setRow( 2, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 2" );
a_Matrix4.setRow( 3, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 3" );
print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" );
print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" );
print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" );
print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" );
a_Matrix4[0] = a_Vector4;
print( a_Matrix4, "set Matrix4[0]" );
a_Matrix4[1] = a_Vector4;
print( a_Matrix4, "set Matrix4[1]" );
a_Matrix4[2] = a_Vector4;
print( a_Matrix4, "set Matrix4[2]" );
a_Matrix4[3] = a_Vector4;
print( a_Matrix4, "set Matrix4[3]" );
a_Matrix4[0] = a_Vector4;
print( a_Matrix4[0], "get Matrix4[0]" );
a_Matrix4[1] = a_Vector4;
print( a_Matrix4[1], "get Matrix4[1]" );
a_Matrix4[2] = a_Vector4;
print( a_Matrix4[2], "get Matrix4[2]" );
a_Matrix4[3] = a_Vector4;
print( a_Matrix4[3], "get Matrix4[3]" );
a_Matrix4.setElem( 0, 0, randfloat() );
a_Matrix4.setElem( 0, 1, randfloat() );
a_Matrix4.setElem( 0, 2, randfloat() );
a_Matrix4.setElem( 0, 3, randfloat() );
a_Matrix4.setElem( 1, 0, randfloat() );
a_Matrix4.setElem( 1, 1, randfloat() );
a_Matrix4.setElem( 1, 2, randfloat() );
a_Matrix4.setElem( 1, 3, randfloat() );
a_Matrix4.setElem( 2, 0, randfloat() );
a_Matrix4.setElem( 2, 1, randfloat() );
a_Matrix4.setElem( 2, 2, randfloat() );
a_Matrix4.setElem( 2, 3, randfloat() );
a_Matrix4.setElem( 3, 0, randfloat() );
a_Matrix4.setElem( 3, 1, randfloat() );
a_Matrix4.setElem( 3, 2, randfloat() );
a_Matrix4.setElem( 3, 3, randfloat() );
print( a_Matrix4, "Matrix4 set elements" );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Transform3 = Transform3( a_Matrix3, a_Vector3 );
print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" );
a_Transform3 = Transform3( a_Quat, a_Vector3 );
print( a_Transform3, "construct Transform3 with Quat and Vector3" );
a_Transform3 = b_Transform3;
print( a_Transform3, "assign to Transform3 from Transform3" );
a_Transform3 = Transform3( randfloat() );
print( a_Transform3, "set Transform3 with float" );
a_Transform3 = Transform3( scalar_float(randfloat()) );
print( a_Transform3, "set Transform3 with float" );
a_Transform3 = Transform3( 0.0f );
print( a_Transform3, "set elements to zero" );
a_Transform3 = Transform3::identity( );
print( a_Transform3, "set to identity" );
a_Transform3 = Transform3::rotationX( randfloat() );
print( a_Transform3, "set to rotationX" );
a_Transform3 = Transform3::rotationY( randfloat() );
print( a_Transform3, "set to rotationY" );
a_Transform3 = Transform3::rotationZ( randfloat() );
print( a_Transform3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Transform3, "set to rotation from Z,Y,X angles" );
a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Transform3, "set to rotation from axis angle" );
a_Transform3 = Transform3::translation( a_Vector3 );
print( a_Transform3, "set to translation" );
a_Transform3.setCol0( a_Vector3 );
print( a_Transform3, "Transform3 set col 0" );
a_Transform3.setCol1( a_Vector3 );
print( a_Transform3, "Transform3 set col 1" );
a_Transform3.setCol2( a_Vector3 );
print( a_Transform3, "Transform3 set col 2" );
a_Transform3.setCol3( a_Vector3 );
print( a_Transform3, "Transform3 set col 3" );
print( a_Transform3.getCol0( ), "Transform3 get col 0" );
print( a_Transform3.getCol1( ), "Transform3 get col 1" );
print( a_Transform3.getCol2( ), "Transform3 get col 2" );
print( a_Transform3.getCol3( ), "Transform3 get col 3" );
a_Transform3.setCol( 0, b_Vector3 );
print( a_Transform3, "Transform3 set col 0" );
a_Transform3.setCol( 1, b_Vector3 );
print( a_Transform3, "Transform3 set col 1" );
a_Transform3.setCol( 2, b_Vector3 );
print( a_Transform3, "Transform3 set col 2" );
a_Transform3.setCol( 3, b_Vector3 );
print( a_Transform3, "Transform3 set col 3" );
print( a_Transform3.getCol( 0 ), "Transform3 get col 0" );
print( a_Transform3.getCol( 1 ), "Transform3 get col 1" );
print( a_Transform3.getCol( 2 ), "Transform3 get col 2" );
print( a_Transform3.getCol( 3 ), "Transform3 get col 3" );
a_Transform3.setRow( 0, a_Vector4 );
print( a_Transform3, "Transform3 set row 0" );
a_Transform3.setRow( 1, a_Vector4 );
print( a_Transform3, "Transform3 set row 1" );
a_Transform3.setRow( 2, a_Vector4 );
print( a_Transform3, "Transform3 set row 2" );
print( a_Transform3.getRow( 0 ), "Transform3 get row 0" );
print( a_Transform3.getRow( 1 ), "Transform3 get row 1" );
print( a_Transform3.getRow( 2 ), "Transform3 get row 2" );
a_Transform3[0] = a_Vector3;
print( a_Transform3, "set Transform3[0]" );
a_Transform3[1] = a_Vector3;
print( a_Transform3, "set Transform3[1]" );
a_Transform3[2] = a_Vector3;
print( a_Transform3, "set Transform3[2]" );
a_Transform3[3] = a_Vector3;
print( a_Transform3, "set Transform3[3]" );
a_Transform3[0] = a_Vector3;
print( a_Transform3[0], "get Transform3[0]" );
a_Transform3[1] = a_Vector3;
print( a_Transform3[1], "get Transform3[1]" );
a_Transform3[2] = a_Vector3;
print( a_Transform3[2], "get Transform3[2]" );
a_Transform3[3] = a_Vector3;
print( a_Transform3[3], "get Transform3[3]" );
a_Transform3.setElem( 0, 0, randfloat() );
a_Transform3.setElem( 0, 1, randfloat() );
a_Transform3.setElem( 0, 2, randfloat() );
a_Transform3.setElem( 1, 0, randfloat() );
a_Transform3.setElem( 1, 1, randfloat() );
a_Transform3.setElem( 1, 2, randfloat() );
a_Transform3.setElem( 2, 0, randfloat() );
a_Transform3.setElem( 2, 1, randfloat() );
a_Transform3.setElem( 2, 2, randfloat() );
a_Transform3.setElem( 3, 0, randfloat() );
a_Transform3.setElem( 3, 1, randfloat() );
a_Transform3.setElem( 3, 2, randfloat() );
print( a_Transform3, "Transform3 set elements" );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,760 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0;
VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaQNormalize( &tmpQ_0, &a_Quat );
vmathSoaM3MakeFromQ( &a_Matrix3, &tmpQ_0 );
vmathSoaM3Prints( &a_Matrix3, "construct Matrix3 with Quat" );
vmathSoaQMakeFromM3( &a_Quat, &a_Matrix3 );
vmathSoaQPrints( &a_Quat, "construct Quat with Matrix3" );
vmathSoaM3Copy( &a_Matrix3, &b_Matrix3 );
vmathSoaM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" );
vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" );
vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" );
vmathSoaM3MakeFromScalar( &a_Matrix3, (vec_float4){0.0f} );
vmathSoaM3Prints( &a_Matrix3, "set elements to zero" );
vmathSoaM3MakeIdentity( &a_Matrix3 );
vmathSoaM3Prints( &a_Matrix3, "set to identity" );
vmathSoaM3MakeRotationX( &a_Matrix3, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "set to rotationX" );
vmathSoaM3MakeRotationY( &a_Matrix3, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "set to rotationY" );
vmathSoaM3MakeRotationZ( &a_Matrix3, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 );
vmathSoaM3MakeRotationZYX( &a_Matrix3, &tmpV3_0 );
vmathSoaM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" );
vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 );
vmathSoaM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_1 );
vmathSoaM3Prints( &a_Matrix3, "set to rotation from axis angle" );
vmathSoaM3SetCol0( &a_Matrix3, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" );
vmathSoaM3SetCol1( &a_Matrix3, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" );
vmathSoaM3SetCol2( &a_Matrix3, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" );
vmathSoaM3GetCol0( &tmpV3_2, &a_Matrix3 );
vmathSoaV3Prints( &tmpV3_2, "Matrix3 get col 0" );
vmathSoaM3GetCol1( &tmpV3_3, &a_Matrix3 );
vmathSoaV3Prints( &tmpV3_3, "Matrix3 get col 1" );
vmathSoaM3GetCol2( &tmpV3_4, &a_Matrix3 );
vmathSoaV3Prints( &tmpV3_4, "Matrix3 get col 2" );
vmathSoaM3SetCol( &a_Matrix3, 0, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" );
vmathSoaM3SetCol( &a_Matrix3, 1, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" );
vmathSoaM3SetCol( &a_Matrix3, 2, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" );
vmathSoaM3GetCol( &tmpV3_5, &a_Matrix3, 0 );
vmathSoaV3Prints( &tmpV3_5, "Matrix3 get col 0" );
vmathSoaM3GetCol( &tmpV3_6, &a_Matrix3, 1 );
vmathSoaV3Prints( &tmpV3_6, "Matrix3 get col 1" );
vmathSoaM3GetCol( &tmpV3_7, &a_Matrix3, 2 );
vmathSoaV3Prints( &tmpV3_7, "Matrix3 get col 2" );
vmathSoaM3SetRow( &a_Matrix3, 0, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 0" );
vmathSoaM3SetRow( &a_Matrix3, 1, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 1" );
vmathSoaM3SetRow( &a_Matrix3, 2, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 2" );
vmathSoaM3GetRow( &tmpV3_8, &a_Matrix3, 0 );
vmathSoaV3Prints( &tmpV3_8, "Matrix3 get row 0" );
vmathSoaM3GetRow( &tmpV3_9, &a_Matrix3, 1 );
vmathSoaV3Prints( &tmpV3_9, "Matrix3 get row 1" );
vmathSoaM3GetRow( &tmpV3_10, &a_Matrix3, 2 );
vmathSoaV3Prints( &tmpV3_10, "Matrix3 get row 2" );
vmathSoaM3SetCol( &a_Matrix3, 0, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set " );
vmathSoaM3SetCol( &a_Matrix3, 1, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set " );
vmathSoaM3SetCol( &a_Matrix3, 2, &a_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set " );
vmathSoaM3GetCol( &tmpV3_11, &a_Matrix3, 0 );
vmathSoaV3Prints( &tmpV3_11, "get " );
vmathSoaM3GetCol( &tmpV3_12, &a_Matrix3, 1 );
vmathSoaV3Prints( &tmpV3_12, "get " );
vmathSoaM3GetCol( &tmpV3_13, &a_Matrix3, 2 );
vmathSoaV3Prints( &tmpV3_13, "get " );
vmathSoaM3SetElem( &a_Matrix3, 0, 0, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 0, 1, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 0, 2, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 1, 0, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 1, 1, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 1, 2, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 2, 0, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 2, 1, randfloat() );
vmathSoaM3SetElem( &a_Matrix3, 2, 2, randfloat() );
vmathSoaM3Prints( &a_Matrix3, "Matrix3 set elements" );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 0 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 1 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 2 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 0 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 1 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 2 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 0 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 1 )) );
printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 2 )) );
}
void
Matrix4_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector3 tmpV3_0, tmpV3_1;
VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaM4MakeFromT3( &a_Matrix4, &a_Transform3 );
vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" );
vmathSoaM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 );
vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" );
vmathSoaM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 );
vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" );
vmathSoaM4Copy( &a_Matrix4, &b_Matrix4 );
vmathSoaM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" );
vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" );
vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" );
vmathSoaM4MakeFromScalar( &a_Matrix4, (vec_float4){0.0f} );
vmathSoaM4Prints( &a_Matrix4, "set elements to zero" );
vmathSoaM4MakeIdentity( &a_Matrix4 );
vmathSoaM4Prints( &a_Matrix4, "set to identity" );
vmathSoaM4MakeRotationX( &a_Matrix4, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "set to rotationX" );
vmathSoaM4MakeRotationY( &a_Matrix4, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "set to rotationY" );
vmathSoaM4MakeRotationZ( &a_Matrix4, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 );
vmathSoaM4MakeRotationZYX( &a_Matrix4, &tmpV3_0 );
vmathSoaM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" );
vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 );
vmathSoaM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_1 );
vmathSoaM4Prints( &a_Matrix4, "set to rotation from axis angle" );
vmathSoaM4MakeTranslation( &a_Matrix4, &a_Vector3 );
vmathSoaM4Prints( &a_Matrix4, "set to translation" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaM4Prints( &a_Matrix4, "set to perspective matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
vmathSoaM4Prints( &a_Matrix4, "set to frustum matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
vmathSoaM4Prints( &a_Matrix4, "set to orthographic matrix" );
vmathSoaM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 );
vmathSoaM4Prints( &a_Matrix4, "set to look-at matrix" );
vmathSoaM4SetCol0( &a_Matrix4, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" );
vmathSoaM4SetCol1( &a_Matrix4, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" );
vmathSoaM4SetCol2( &a_Matrix4, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" );
vmathSoaM4SetCol3( &a_Matrix4, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" );
vmathSoaM4GetCol0( &tmpV4_0, &a_Matrix4 );
vmathSoaV4Prints( &tmpV4_0, "Matrix4 get col 0" );
vmathSoaM4GetCol1( &tmpV4_1, &a_Matrix4 );
vmathSoaV4Prints( &tmpV4_1, "Matrix4 get col 1" );
vmathSoaM4GetCol2( &tmpV4_2, &a_Matrix4 );
vmathSoaV4Prints( &tmpV4_2, "Matrix4 get col 2" );
vmathSoaM4GetCol3( &tmpV4_3, &a_Matrix4 );
vmathSoaV4Prints( &tmpV4_3, "Matrix4 get col 3" );
vmathSoaM4SetCol( &a_Matrix4, 0, &b_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" );
vmathSoaM4SetCol( &a_Matrix4, 1, &b_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" );
vmathSoaM4SetCol( &a_Matrix4, 2, &b_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" );
vmathSoaM4SetCol( &a_Matrix4, 3, &b_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" );
vmathSoaM4GetCol( &tmpV4_4, &a_Matrix4, 0 );
vmathSoaV4Prints( &tmpV4_4, "Matrix4 get col 0" );
vmathSoaM4GetCol( &tmpV4_5, &a_Matrix4, 1 );
vmathSoaV4Prints( &tmpV4_5, "Matrix4 get col 1" );
vmathSoaM4GetCol( &tmpV4_6, &a_Matrix4, 2 );
vmathSoaV4Prints( &tmpV4_6, "Matrix4 get col 2" );
vmathSoaM4GetCol( &tmpV4_7, &a_Matrix4, 3 );
vmathSoaV4Prints( &tmpV4_7, "Matrix4 get col 3" );
vmathSoaM4SetRow( &a_Matrix4, 0, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 0" );
vmathSoaM4SetRow( &a_Matrix4, 1, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 1" );
vmathSoaM4SetRow( &a_Matrix4, 2, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 2" );
vmathSoaM4SetRow( &a_Matrix4, 3, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 3" );
vmathSoaM4GetRow( &tmpV4_8, &a_Matrix4, 0 );
vmathSoaV4Prints( &tmpV4_8, "Matrix4 get row 0" );
vmathSoaM4GetRow( &tmpV4_9, &a_Matrix4, 1 );
vmathSoaV4Prints( &tmpV4_9, "Matrix4 get row 1" );
vmathSoaM4GetRow( &tmpV4_10, &a_Matrix4, 2 );
vmathSoaV4Prints( &tmpV4_10, "Matrix4 get row 2" );
vmathSoaM4GetRow( &tmpV4_11, &a_Matrix4, 3 );
vmathSoaV4Prints( &tmpV4_11, "Matrix4 get row 3" );
vmathSoaM4SetCol( &a_Matrix4, 0, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set " );
vmathSoaM4SetCol( &a_Matrix4, 1, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set " );
vmathSoaM4SetCol( &a_Matrix4, 2, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set " );
vmathSoaM4SetCol( &a_Matrix4, 3, &a_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set " );
vmathSoaM4GetCol( &tmpV4_12, &a_Matrix4, 0 );
vmathSoaV4Prints( &tmpV4_12, "get " );
vmathSoaM4GetCol( &tmpV4_13, &a_Matrix4, 1 );
vmathSoaV4Prints( &tmpV4_13, "get " );
vmathSoaM4GetCol( &tmpV4_14, &a_Matrix4, 2 );
vmathSoaV4Prints( &tmpV4_14, "get " );
vmathSoaM4GetCol( &tmpV4_15, &a_Matrix4, 3 );
vmathSoaV4Prints( &tmpV4_15, "get " );
vmathSoaM4SetElem( &a_Matrix4, 0, 0, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 0, 1, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 0, 2, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 0, 3, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 1, 0, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 1, 1, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 1, 2, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 1, 3, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 2, 0, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 2, 1, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 2, 2, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 2, 3, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 3, 0, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 3, 1, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 3, 2, randfloat() );
vmathSoaM4SetElem( &a_Matrix4, 3, 3, randfloat() );
vmathSoaM4Prints( &a_Matrix4, "Matrix4 set elements" );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 0 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 1 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 2 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 3 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 0 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 1 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 2 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 3 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 0 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 1 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 2 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 3 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 0 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 1 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 2 )) );
printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 3 )) );
}
void
Transform3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9;
VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2;
VmathSoaVector3 tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" );
vmathSoaT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" );
vmathSoaT3Copy( &a_Transform3, &b_Transform3 );
vmathSoaT3Prints( &a_Transform3, "assign to Transform3 from Transform3" );
vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() );
vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" );
vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() );
vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" );
vmathSoaT3MakeFromScalar( &a_Transform3, (vec_float4){0.0f} );
vmathSoaT3Prints( &a_Transform3, "set elements to zero" );
vmathSoaT3MakeIdentity( &a_Transform3 );
vmathSoaT3Prints( &a_Transform3, "set to identity" );
vmathSoaT3MakeRotationX( &a_Transform3, randfloat() );
vmathSoaT3Prints( &a_Transform3, "set to rotationX" );
vmathSoaT3MakeRotationY( &a_Transform3, randfloat() );
vmathSoaT3Prints( &a_Transform3, "set to rotationY" );
vmathSoaT3MakeRotationZ( &a_Transform3, randfloat() );
vmathSoaT3Prints( &a_Transform3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 );
vmathSoaT3MakeRotationZYX( &a_Transform3, &tmpV3_0 );
vmathSoaT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" );
vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 );
vmathSoaT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_1 );
vmathSoaT3Prints( &a_Transform3, "set to rotation from axis angle" );
vmathSoaT3MakeTranslation( &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set to translation" );
vmathSoaT3SetCol0( &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" );
vmathSoaT3SetCol1( &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" );
vmathSoaT3SetCol2( &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" );
vmathSoaT3SetCol3( &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" );
vmathSoaT3GetCol0( &tmpV3_2, &a_Transform3 );
vmathSoaV3Prints( &tmpV3_2, "Transform3 get col 0" );
vmathSoaT3GetCol1( &tmpV3_3, &a_Transform3 );
vmathSoaV3Prints( &tmpV3_3, "Transform3 get col 1" );
vmathSoaT3GetCol2( &tmpV3_4, &a_Transform3 );
vmathSoaV3Prints( &tmpV3_4, "Transform3 get col 2" );
vmathSoaT3GetCol3( &tmpV3_5, &a_Transform3 );
vmathSoaV3Prints( &tmpV3_5, "Transform3 get col 3" );
vmathSoaT3SetCol( &a_Transform3, 0, &b_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" );
vmathSoaT3SetCol( &a_Transform3, 1, &b_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" );
vmathSoaT3SetCol( &a_Transform3, 2, &b_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" );
vmathSoaT3SetCol( &a_Transform3, 3, &b_Vector3 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" );
vmathSoaT3GetCol( &tmpV3_6, &a_Transform3, 0 );
vmathSoaV3Prints( &tmpV3_6, "Transform3 get col 0" );
vmathSoaT3GetCol( &tmpV3_7, &a_Transform3, 1 );
vmathSoaV3Prints( &tmpV3_7, "Transform3 get col 1" );
vmathSoaT3GetCol( &tmpV3_8, &a_Transform3, 2 );
vmathSoaV3Prints( &tmpV3_8, "Transform3 get col 2" );
vmathSoaT3GetCol( &tmpV3_9, &a_Transform3, 3 );
vmathSoaV3Prints( &tmpV3_9, "Transform3 get col 3" );
vmathSoaT3SetRow( &a_Transform3, 0, &a_Vector4 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set row 0" );
vmathSoaT3SetRow( &a_Transform3, 1, &a_Vector4 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set row 1" );
vmathSoaT3SetRow( &a_Transform3, 2, &a_Vector4 );
vmathSoaT3Prints( &a_Transform3, "Transform3 set row 2" );
vmathSoaT3GetRow( &tmpV4_0, &a_Transform3, 0 );
vmathSoaV4Prints( &tmpV4_0, "Transform3 get row 0" );
vmathSoaT3GetRow( &tmpV4_1, &a_Transform3, 1 );
vmathSoaV4Prints( &tmpV4_1, "Transform3 get row 1" );
vmathSoaT3GetRow( &tmpV4_2, &a_Transform3, 2 );
vmathSoaV4Prints( &tmpV4_2, "Transform3 get row 2" );
vmathSoaT3SetCol( &a_Transform3, 0, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set " );
vmathSoaT3SetCol( &a_Transform3, 1, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set " );
vmathSoaT3SetCol( &a_Transform3, 2, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set " );
vmathSoaT3SetCol( &a_Transform3, 3, &a_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set " );
vmathSoaT3GetCol( &tmpV3_10, &a_Transform3, 0 );
vmathSoaV3Prints( &tmpV3_10, "get " );
vmathSoaT3GetCol( &tmpV3_11, &a_Transform3, 1 );
vmathSoaV3Prints( &tmpV3_11, "get " );
vmathSoaT3GetCol( &tmpV3_12, &a_Transform3, 2 );
vmathSoaV3Prints( &tmpV3_12, "get " );
vmathSoaT3GetCol( &tmpV3_13, &a_Transform3, 3 );
vmathSoaV3Prints( &tmpV3_13, "get " );
vmathSoaT3SetElem( &a_Transform3, 0, 0, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 0, 1, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 0, 2, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 1, 0, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 1, 1, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 1, 2, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 2, 0, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 2, 1, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 2, 2, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 3, 0, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 3, 1, randfloat() );
vmathSoaT3SetElem( &a_Transform3, 3, 2, randfloat() );
vmathSoaT3Prints( &a_Transform3, "Transform3 set elements" );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 0 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 1 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 2 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 0 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 1 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 2 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 0 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 1 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 2 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 0 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 1 )) );
printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 2 )) );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,718 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Soa;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Matrix3 = Matrix3( normalize( a_Quat ) );
print( a_Matrix3, "construct Matrix3 with Quat" );
a_Quat = Quat( a_Matrix3 );
print( a_Quat, "construct Quat with Matrix3" );
a_Matrix3 = b_Matrix3;
print( a_Matrix3, "assign to Matrix3 from Matrix3" );
a_Matrix3 = Matrix3( randfloat() );
print( a_Matrix3, "set Matrix3 with float" );
a_Matrix3 = Matrix3( randfloat() );
print( a_Matrix3, "set Matrix3 with float" );
a_Matrix3 = Matrix3( (vec_float4){0.0f} );
print( a_Matrix3, "set elements to zero" );
a_Matrix3 = Matrix3::identity( );
print( a_Matrix3, "set to identity" );
a_Matrix3 = Matrix3::rotationX( randfloat() );
print( a_Matrix3, "set to rotationX" );
a_Matrix3 = Matrix3::rotationY( randfloat() );
print( a_Matrix3, "set to rotationY" );
a_Matrix3 = Matrix3::rotationZ( randfloat() );
print( a_Matrix3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Matrix3, "set to rotation from Z,Y,X angles" );
a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Matrix3, "set to rotation from axis angle" );
a_Matrix3.setCol0( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 0" );
a_Matrix3.setCol1( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 1" );
a_Matrix3.setCol2( a_Vector3 );
print( a_Matrix3, "Matrix3 set col 2" );
print( a_Matrix3.getCol0( ), "Matrix3 get col 0" );
print( a_Matrix3.getCol1( ), "Matrix3 get col 1" );
print( a_Matrix3.getCol2( ), "Matrix3 get col 2" );
a_Matrix3.setCol( 0, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 0" );
a_Matrix3.setCol( 1, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 1" );
a_Matrix3.setCol( 2, b_Vector3 );
print( a_Matrix3, "Matrix3 set col 2" );
print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" );
print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" );
print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" );
a_Matrix3.setRow( 0, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 0" );
a_Matrix3.setRow( 1, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 1" );
a_Matrix3.setRow( 2, a_Vector3 );
print( a_Matrix3, "Matrix3 set row 2" );
print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" );
print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" );
print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" );
a_Matrix3[0] = a_Vector3;
print( a_Matrix3, "set Matrix3[0]" );
a_Matrix3[1] = a_Vector3;
print( a_Matrix3, "set Matrix3[1]" );
a_Matrix3[2] = a_Vector3;
print( a_Matrix3, "set Matrix3[2]" );
a_Matrix3[0] = a_Vector3;
print( a_Matrix3[0], "get Matrix3[0]" );
a_Matrix3[1] = a_Vector3;
print( a_Matrix3[1], "get Matrix3[1]" );
a_Matrix3[2] = a_Vector3;
print( a_Matrix3[2], "get Matrix3[2]" );
a_Matrix3.setElem( 0, 0, randfloat() );
a_Matrix3.setElem( 0, 1, randfloat() );
a_Matrix3.setElem( 0, 2, randfloat() );
a_Matrix3.setElem( 1, 0, randfloat() );
a_Matrix3.setElem( 1, 1, randfloat() );
a_Matrix3.setElem( 1, 2, randfloat() );
a_Matrix3.setElem( 2, 0, randfloat() );
a_Matrix3.setElem( 2, 1, randfloat() );
a_Matrix3.setElem( 2, 2, randfloat() );
print( a_Matrix3, "Matrix3 set elements" );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Matrix4 = Matrix4( a_Transform3 );
print( a_Matrix4, "construct Matrix4 with Transform3" );
a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 );
print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" );
a_Matrix4 = Matrix4( a_Quat, a_Vector3 );
print( a_Matrix4, "construct Matrix4 with Quat and Vector3" );
a_Matrix4 = b_Matrix4;
print( a_Matrix4, "assign to Matrix4 from Matrix4" );
a_Matrix4 = Matrix4( randfloat() );
print( a_Matrix4, "set Matrix4 with float" );
a_Matrix4 = Matrix4( randfloat() );
print( a_Matrix4, "set Matrix4 with float" );
a_Matrix4 = Matrix4( (vec_float4){0.0f} );
print( a_Matrix4, "set elements to zero" );
a_Matrix4 = Matrix4::identity( );
print( a_Matrix4, "set to identity" );
a_Matrix4 = Matrix4::rotationX( randfloat() );
print( a_Matrix4, "set to rotationX" );
a_Matrix4 = Matrix4::rotationY( randfloat() );
print( a_Matrix4, "set to rotationY" );
a_Matrix4 = Matrix4::rotationZ( randfloat() );
print( a_Matrix4, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Matrix4, "set to rotation from Z,Y,X angles" );
a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Matrix4, "set to rotation from axis angle" );
a_Matrix4 = Matrix4::translation( a_Vector3 );
print( a_Matrix4, "set to translation" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Matrix4, "set to perspective matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
print( a_Matrix4, "set to frustum matrix" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 );
print( a_Matrix4, "set to orthographic matrix" );
a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 );
print( a_Matrix4, "set to look-at matrix" );
a_Matrix4.setCol0( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 0" );
a_Matrix4.setCol1( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 1" );
a_Matrix4.setCol2( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 2" );
a_Matrix4.setCol3( a_Vector4 );
print( a_Matrix4, "Matrix4 set col 3" );
print( a_Matrix4.getCol0( ), "Matrix4 get col 0" );
print( a_Matrix4.getCol1( ), "Matrix4 get col 1" );
print( a_Matrix4.getCol2( ), "Matrix4 get col 2" );
print( a_Matrix4.getCol3( ), "Matrix4 get col 3" );
a_Matrix4.setCol( 0, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 0" );
a_Matrix4.setCol( 1, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 1" );
a_Matrix4.setCol( 2, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 2" );
a_Matrix4.setCol( 3, b_Vector4 );
print( a_Matrix4, "Matrix4 set col 3" );
print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" );
print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" );
print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" );
print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" );
a_Matrix4.setRow( 0, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 0" );
a_Matrix4.setRow( 1, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 1" );
a_Matrix4.setRow( 2, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 2" );
a_Matrix4.setRow( 3, a_Vector4 );
print( a_Matrix4, "Matrix4 set row 3" );
print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" );
print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" );
print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" );
print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" );
a_Matrix4[0] = a_Vector4;
print( a_Matrix4, "set Matrix4[0]" );
a_Matrix4[1] = a_Vector4;
print( a_Matrix4, "set Matrix4[1]" );
a_Matrix4[2] = a_Vector4;
print( a_Matrix4, "set Matrix4[2]" );
a_Matrix4[3] = a_Vector4;
print( a_Matrix4, "set Matrix4[3]" );
a_Matrix4[0] = a_Vector4;
print( a_Matrix4[0], "get Matrix4[0]" );
a_Matrix4[1] = a_Vector4;
print( a_Matrix4[1], "get Matrix4[1]" );
a_Matrix4[2] = a_Vector4;
print( a_Matrix4[2], "get Matrix4[2]" );
a_Matrix4[3] = a_Vector4;
print( a_Matrix4[3], "get Matrix4[3]" );
a_Matrix4.setElem( 0, 0, randfloat() );
a_Matrix4.setElem( 0, 1, randfloat() );
a_Matrix4.setElem( 0, 2, randfloat() );
a_Matrix4.setElem( 0, 3, randfloat() );
a_Matrix4.setElem( 1, 0, randfloat() );
a_Matrix4.setElem( 1, 1, randfloat() );
a_Matrix4.setElem( 1, 2, randfloat() );
a_Matrix4.setElem( 1, 3, randfloat() );
a_Matrix4.setElem( 2, 0, randfloat() );
a_Matrix4.setElem( 2, 1, randfloat() );
a_Matrix4.setElem( 2, 2, randfloat() );
a_Matrix4.setElem( 2, 3, randfloat() );
a_Matrix4.setElem( 3, 0, randfloat() );
a_Matrix4.setElem( 3, 1, randfloat() );
a_Matrix4.setElem( 3, 2, randfloat() );
a_Matrix4.setElem( 3, 3, randfloat() );
print( a_Matrix4, "Matrix4 set elements" );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) );
printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
a_Transform3 = Transform3( a_Matrix3, a_Vector3 );
print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" );
a_Transform3 = Transform3( a_Quat, a_Vector3 );
print( a_Transform3, "construct Transform3 with Quat and Vector3" );
a_Transform3 = b_Transform3;
print( a_Transform3, "assign to Transform3 from Transform3" );
a_Transform3 = Transform3( randfloat() );
print( a_Transform3, "set Transform3 with float" );
a_Transform3 = Transform3( randfloat() );
print( a_Transform3, "set Transform3 with float" );
a_Transform3 = Transform3( (vec_float4){0.0f} );
print( a_Transform3, "set elements to zero" );
a_Transform3 = Transform3::identity( );
print( a_Transform3, "set to identity" );
a_Transform3 = Transform3::rotationX( randfloat() );
print( a_Transform3, "set to rotationX" );
a_Transform3 = Transform3::rotationY( randfloat() );
print( a_Transform3, "set to rotationY" );
a_Transform3 = Transform3::rotationZ( randfloat() );
print( a_Transform3, "set to rotationZ" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) );
print( a_Transform3, "set to rotation from Z,Y,X angles" );
a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) );
print( a_Transform3, "set to rotation from axis angle" );
a_Transform3 = Transform3::translation( a_Vector3 );
print( a_Transform3, "set to translation" );
a_Transform3.setCol0( a_Vector3 );
print( a_Transform3, "Transform3 set col 0" );
a_Transform3.setCol1( a_Vector3 );
print( a_Transform3, "Transform3 set col 1" );
a_Transform3.setCol2( a_Vector3 );
print( a_Transform3, "Transform3 set col 2" );
a_Transform3.setCol3( a_Vector3 );
print( a_Transform3, "Transform3 set col 3" );
print( a_Transform3.getCol0( ), "Transform3 get col 0" );
print( a_Transform3.getCol1( ), "Transform3 get col 1" );
print( a_Transform3.getCol2( ), "Transform3 get col 2" );
print( a_Transform3.getCol3( ), "Transform3 get col 3" );
a_Transform3.setCol( 0, b_Vector3 );
print( a_Transform3, "Transform3 set col 0" );
a_Transform3.setCol( 1, b_Vector3 );
print( a_Transform3, "Transform3 set col 1" );
a_Transform3.setCol( 2, b_Vector3 );
print( a_Transform3, "Transform3 set col 2" );
a_Transform3.setCol( 3, b_Vector3 );
print( a_Transform3, "Transform3 set col 3" );
print( a_Transform3.getCol( 0 ), "Transform3 get col 0" );
print( a_Transform3.getCol( 1 ), "Transform3 get col 1" );
print( a_Transform3.getCol( 2 ), "Transform3 get col 2" );
print( a_Transform3.getCol( 3 ), "Transform3 get col 3" );
a_Transform3.setRow( 0, a_Vector4 );
print( a_Transform3, "Transform3 set row 0" );
a_Transform3.setRow( 1, a_Vector4 );
print( a_Transform3, "Transform3 set row 1" );
a_Transform3.setRow( 2, a_Vector4 );
print( a_Transform3, "Transform3 set row 2" );
print( a_Transform3.getRow( 0 ), "Transform3 get row 0" );
print( a_Transform3.getRow( 1 ), "Transform3 get row 1" );
print( a_Transform3.getRow( 2 ), "Transform3 get row 2" );
a_Transform3[0] = a_Vector3;
print( a_Transform3, "set Transform3[0]" );
a_Transform3[1] = a_Vector3;
print( a_Transform3, "set Transform3[1]" );
a_Transform3[2] = a_Vector3;
print( a_Transform3, "set Transform3[2]" );
a_Transform3[3] = a_Vector3;
print( a_Transform3, "set Transform3[3]" );
a_Transform3[0] = a_Vector3;
print( a_Transform3[0], "get Transform3[0]" );
a_Transform3[1] = a_Vector3;
print( a_Transform3[1], "get Transform3[1]" );
a_Transform3[2] = a_Vector3;
print( a_Transform3[2], "get Transform3[2]" );
a_Transform3[3] = a_Vector3;
print( a_Transform3[3], "get Transform3[3]" );
a_Transform3.setElem( 0, 0, randfloat() );
a_Transform3.setElem( 0, 1, randfloat() );
a_Transform3.setElem( 0, 2, randfloat() );
a_Transform3.setElem( 1, 0, randfloat() );
a_Transform3.setElem( 1, 1, randfloat() );
a_Transform3.setElem( 1, 2, randfloat() );
a_Transform3.setElem( 2, 0, randfloat() );
a_Transform3.setElem( 2, 1, randfloat() );
a_Transform3.setElem( 2, 2, randfloat() );
a_Transform3.setElem( 3, 0, randfloat() );
a_Transform3.setElem( 3, 1, randfloat() );
a_Transform3.setElem( 3, 2, randfloat() );
print( a_Transform3, "Transform3 set elements" );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) );
printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,524 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 );
vmathM3Prints( &tmpM3_0, "Matrix3 + Matrix3" );
vmathM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 );
vmathM3Prints( &tmpM3_1, "Matrix3 - Matrix3" );
vmathM3Neg( &tmpM3_2, &a_Matrix3 );
vmathM3Prints( &tmpM3_2, "-Matrix3" );
vmathM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() );
vmathM3Prints( &tmpM3_3, "Matrix3 * float" );
vmathM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() );
vmathM3Prints( &tmpM3_4, "float * Matrix3" );
vmathM3MulV3( &tmpV3_8, &a_Matrix3, &a_Vector3 );
vmathV3Prints( &tmpV3_8, "Matrix3 * Vector3" );
vmathM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 );
vmathM3Prints( &tmpM3_5, "Matrix3 * Matrix3" );
}
void
Matrix4_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7;
VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 );
vmathM4Prints( &tmpM4_0, "Matrix4 + Matrix4" );
vmathM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 );
vmathM4Prints( &tmpM4_1, "Matrix4 - Matrix4" );
vmathM4Neg( &tmpM4_2, &a_Matrix4 );
vmathM4Prints( &tmpM4_2, "-Matrix4" );
vmathM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() );
vmathM4Prints( &tmpM4_3, "Matrix4 * float" );
vmathM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() );
vmathM4Prints( &tmpM4_4, "float * Matrix4" );
vmathM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 );
vmathV4Prints( &tmpV4_0, "Matrix4 * Vector4" );
vmathM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 );
vmathV4Prints( &tmpV4_1, "Matrix4 * Vector3" );
vmathM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 );
vmathV4Prints( &tmpV4_2, "Matrix4 * Point3" );
vmathM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 );
vmathM4Prints( &tmpM4_5, "Matrix4 * Matrix4" );
vmathM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 );
vmathM4Prints( &tmpM4_6, "Matrix4 * Transform3" );
}
void
Transform3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3, tmpT3_0;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8;
VmathPoint3 tmpP3_0;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathT3MulV3( &tmpV3_8, &a_Transform3, &a_Vector3 );
vmathV3Prints( &tmpV3_8, "Transform3 * Vector3" );
vmathT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 );
vmathP3Prints( &tmpP3_0, "Transform3 * Point3" );
vmathT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 );
vmathT3Prints( &tmpT3_0, "Transform3 * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,476 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Aos;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" );
print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" );
print( ( -a_Matrix3 ), "-Matrix3" );
print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" );
print( ( randfloat() * a_Matrix3 ), "float * Matrix3" );
print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" );
print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" );
print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" );
print( ( -a_Matrix4 ), "-Matrix4" );
print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" );
print( ( randfloat() * a_Matrix4 ), "float * Matrix4" );
print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" );
print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" );
print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" );
print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" );
print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" );
print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" );
print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,392 @@
set Vector3 with floats: ( -0.658344 0.499804 -0.807257 )
set Vector3 with floats: ( 0.740930 0.154607 0.571599 )
set Vector3 with floats: ( 0.384388 -0.262467 0.747808 )
set Vector3 with floats: ( 0.490190 -0.107908 -0.292544 )
set Vector4 with floats: ( 0.465039 -0.479556 -0.211412 0.553580 )
set Vector4 with floats: ( 0.690070 0.151576 0.431077 -0.833992 )
set Vector4 with floats: ( -0.088350 -0.780106 0.090456 -0.218627 )
set Vector4 with floats: ( 0.137171 0.918133 0.735438 -0.673621 )
set Point3 with floats: ( -0.448982 -0.479278 0.848189 )
set Point3 with floats: ( -0.128155 0.578922 -0.744766 )
set Point3 with floats: ( -0.835589 0.881284 -0.948850 )
set Point3 with floats: ( -0.691578 -0.235635 -0.690527 )
set Quat with floats: ( 0.058667 0.753697 -0.138777 -0.472188 )
set Quat with floats: ( -0.372811 0.540183 -0.785218 0.542085 )
set Quat with floats: ( 0.410391 -0.562721 0.523588 -0.176574 )
set Quat with floats: ( 0.297654 0.859913 0.004837 0.374881 )
set Matrix3 columns:
( -0.658344 0.740930 0.384388 )
( 0.499804 0.154607 -0.262467 )
( -0.807257 0.571599 0.747808 )
set Matrix3 columns:
( 0.490190 -0.658344 0.740930 )
( -0.107908 0.499804 0.154607 )
( -0.292544 -0.807257 0.571599 )
set Matrix4 columns:
( 0.465039 0.690070 -0.088350 0.137171 )
( -0.479556 0.151576 -0.780106 0.918133 )
( -0.211412 0.431077 0.090456 0.735438 )
( 0.553580 -0.833992 -0.218627 -0.673621 )
set Matrix4 columns:
( 0.137171 0.465039 0.690070 -0.088350 )
( 0.918133 -0.479556 0.151576 -0.780106 )
( 0.735438 -0.211412 0.431077 0.090456 )
( -0.673621 0.553580 -0.833992 -0.218627 )
set Transform3 columns:
( -0.658344 0.740930 0.384388 0.490190 )
( 0.499804 0.154607 -0.262467 -0.107908 )
( -0.807257 0.571599 0.747808 -0.292544 )
set Transform3 columns:
( 0.490190 -0.658344 0.740930 0.384388 )
( -0.107908 0.499804 0.154607 -0.262467 )
( -0.292544 -0.807257 0.571599 0.747808 )
Matrix3 + Matrix3:
( -0.168154 0.082587 1.125319 )
( 0.391896 0.654411 -0.107860 )
( -1.099800 -0.235658 1.319407 )
Matrix3 - Matrix3:
( -1.148534 1.399274 -0.356542 )
( 0.607712 -0.345197 -0.417075 )
( -0.514713 1.378855 0.176210 )
-Matrix3:
( 0.658344 -0.740930 -0.384388 )
( -0.499804 -0.154607 0.262467 )
( 0.807257 -0.571599 -0.747808 )
Matrix3 * float:
( 0.084148 -0.094704 -0.049132 )
( -0.063884 -0.019762 0.033548 )
( 0.103182 -0.073061 -0.095583 )
float * Matrix3:
( -0.142598 0.160487 0.083259 )
( 0.108258 0.033488 -0.056851 )
( -0.174853 0.123809 0.161977 )
Matrix3 * Vector3: ( 0.493437 -0.039891 0.213467 )
Matrix3 * Matrix3:
( -0.515117 0.493437 -0.153518 )
( 0.305099 -0.039891 0.244197 )
( -0.676156 0.213467 -0.082302 )
set Vector3 with floats: ( 0.153117 0.265243 -0.073149 )
set Vector3 with floats: ( 0.264488 -0.723410 0.921523 )
set Vector3 with floats: ( -0.711250 -0.106634 -0.350831 )
set Vector3 with floats: ( 0.905168 -0.283632 -0.203584 )
set Vector4 with floats: ( -0.797437 0.910171 0.969234 0.151940 )
set Vector4 with floats: ( 0.731827 -0.700248 0.818301 0.302505 )
set Vector4 with floats: ( -0.872278 0.909999 0.932526 0.571087 )
set Vector4 with floats: ( 0.610330 0.142507 -0.434829 0.925102 )
set Point3 with floats: ( 0.158954 -0.126283 -0.249128 )
set Point3 with floats: ( 0.846815 -0.942601 0.537720 )
set Point3 with floats: ( 0.446214 0.181939 -0.148223 )
set Point3 with floats: ( 0.284286 0.493525 -0.861963 )
set Quat with floats: ( -0.893410 0.548627 0.407007 -0.757467 )
set Quat with floats: ( -0.393126 -0.850984 0.375720 -0.270088 )
set Quat with floats: ( 0.458888 -0.610828 -0.690816 -0.676415 )
set Quat with floats: ( 0.664466 0.101874 -0.365714 0.055473 )
set Matrix3 columns:
( 0.153117 0.264488 -0.711250 )
( 0.265243 -0.723410 -0.106634 )
( -0.073149 0.921523 -0.350831 )
set Matrix3 columns:
( 0.905168 0.153117 0.264488 )
( -0.283632 0.265243 -0.723410 )
( -0.203584 -0.073149 0.921523 )
set Matrix4 columns:
( -0.797437 0.731827 -0.872278 0.610330 )
( 0.910171 -0.700248 0.909999 0.142507 )
( 0.969234 0.818301 0.932526 -0.434829 )
( 0.151940 0.302505 0.571087 0.925102 )
set Matrix4 columns:
( 0.610330 -0.797437 0.731827 -0.872278 )
( 0.142507 0.910171 -0.700248 0.909999 )
( -0.434829 0.969234 0.818301 0.932526 )
( 0.925102 0.151940 0.302505 0.571087 )
set Transform3 columns:
( 0.153117 0.264488 -0.711250 0.905168 )
( 0.265243 -0.723410 -0.106634 -0.283632 )
( -0.073149 0.921523 -0.350831 -0.203584 )
set Transform3 columns:
( 0.905168 0.153117 0.264488 -0.711250 )
( -0.283632 0.265243 -0.723410 -0.106634 )
( -0.203584 -0.073149 0.921523 -0.350831 )
Matrix4 + Matrix4:
( -0.187107 -0.065609 -0.140451 -0.261949 )
( 1.052679 0.209923 0.209751 1.052506 )
( 0.534405 1.787535 1.750826 0.497697 )
( 1.077042 0.454445 0.873592 1.496189 )
Matrix4 - Matrix4:
( -1.407767 1.529264 -1.604106 1.482608 )
( 0.767664 -1.610420 1.610247 -0.767491 )
( 1.404062 -0.150933 0.114225 -1.367354 )
( -0.773162 0.150565 0.268582 0.354015 )
-Matrix4:
( 0.797437 -0.731827 0.872278 -0.610330 )
( -0.910171 0.700248 -0.909999 -0.142507 )
( -0.969234 -0.818301 -0.932526 0.434829 )
( -0.151940 -0.302505 -0.571087 -0.925102 )
Matrix4 * float:
( 0.106503 -0.097740 0.116498 -0.081513 )
( -0.121559 0.093522 -0.121536 -0.019033 )
( -0.129447 -0.109289 -0.124544 0.058074 )
( -0.020293 -0.040401 -0.076272 -0.123553 )
float * Matrix4:
( 0.456647 -0.419076 0.499504 -0.349501 )
( -0.521203 0.400992 -0.521105 -0.081606 )
( -0.555025 -0.468594 -0.534004 0.249002 )
( -0.087007 -0.173227 -0.327029 -0.529753 )
Matrix4 * Vector4: ( 0.549286 -0.459496 0.809659 0.848246 )
Matrix4 * Vector3: ( 0.135817 -0.112939 0.297242 0.061728 )
Matrix4 * Point3: ( 0.608465 0.148906 -0.616420 0.768779 )
Matrix4 * Matrix4:
( 0.561500 0.549286 -1.625205 0.896678 )
( 0.191855 -0.459496 1.944198 -0.501167 )
( -0.099583 0.809659 0.767847 0.520490 )
( 0.743332 0.848246 0.646534 1.203612 )
Matrix4 * Transform3:
( -0.751803 0.135817 -1.544148 1.405491 )
( 0.837210 -0.112939 1.585880 -0.749438 )
( 0.455376 0.297242 0.523727 -1.538614 )
( -0.064533 0.061728 0.347621 0.584422 )
set Vector3 with floats: ( 0.459209 -0.997261 0.172409 )
set Vector3 with floats: ( -0.045124 0.879716 0.524317 )
set Vector3 with floats: ( -0.744532 -0.970444 -0.000013 )
set Vector3 with floats: ( 0.689543 0.704297 -0.817983 )
set Vector4 with floats: ( 0.715505 0.577868 0.156952 -0.801022 )
set Vector4 with floats: ( 0.656335 0.494393 0.816743 0.024285 )
set Vector4 with floats: ( 0.769132 0.923895 0.133022 -0.052219 )
set Vector4 with floats: ( -0.164886 0.300690 0.760403 0.171869 )
set Point3 with floats: ( -0.554976 0.998693 -0.681641 )
set Point3 with floats: ( 0.391195 0.403059 0.972411 )
set Point3 with floats: ( 0.297195 0.309761 0.688408 )
set Point3 with floats: ( 0.363540 0.940297 -0.336683 )
set Quat with floats: ( 0.600164 -0.681272 0.726558 0.205513 )
set Quat with floats: ( -0.160082 0.962714 0.737794 -0.071926 )
set Quat with floats: ( -0.506313 0.689277 0.686485 0.473013 )
set Quat with floats: ( -0.735610 -0.046390 0.568674 -0.004815 )
set Matrix3 columns:
( 0.459209 -0.045124 -0.744532 )
( -0.997261 0.879716 -0.970444 )
( 0.172409 0.524317 -0.000013 )
set Matrix3 columns:
( 0.689543 0.459209 -0.045124 )
( 0.704297 -0.997261 0.879716 )
( -0.817983 0.172409 0.524317 )
set Matrix4 columns:
( 0.715505 0.656335 0.769132 -0.164886 )
( 0.577868 0.494393 0.923895 0.300690 )
( 0.156952 0.816743 0.133022 0.760403 )
( -0.801022 0.024285 -0.052219 0.171869 )
set Matrix4 columns:
( -0.164886 0.715505 0.656335 0.769132 )
( 0.300690 0.577868 0.494393 0.923895 )
( 0.760403 0.156952 0.816743 0.133022 )
( 0.171869 -0.801022 0.024285 -0.052219 )
set Transform3 columns:
( 0.459209 -0.045124 -0.744532 0.689543 )
( -0.997261 0.879716 -0.970444 0.704297 )
( 0.172409 0.524317 -0.000013 -0.817983 )
set Transform3 columns:
( 0.689543 0.459209 -0.045124 -0.744532 )
( 0.704297 -0.997261 0.879716 -0.970444 )
( -0.817983 0.172409 0.524317 -0.000013 )
Transform3 * Vector3: ( 0.127510 -1.502572 -0.443712 )
Transform3 * Point3: ( 0.897132 2.797814 -0.390025 )
Transform3 * Transform3:
( 0.893878 0.127510 -0.450789 0.391447 )
( 0.725733 -1.502572 0.310080 0.593088 )
( 0.488169 -0.443712 0.453463 -1.455167 )
set Vector3 with floats: ( 0.137637 -0.111879 -0.929543 )
set Vector3 with floats: ( -0.336303 -0.146740 0.165140 )
set Vector3 with floats: ( -0.823874 0.349776 0.174872 )
set Vector3 with floats: ( -0.528584 0.489292 0.916708 )
set Vector4 with floats: ( 0.728511 -0.851140 0.079620 -0.234370 )
set Vector4 with floats: ( -0.996308 0.433229 -0.892684 -0.957911 )
set Vector4 with floats: ( 0.517122 0.257921 0.862028 0.095881 )
set Vector4 with floats: ( -0.171933 -0.214078 -0.604841 -0.383831 )
set Point3 with floats: ( -0.581500 0.222183 -0.256120 )
set Point3 with floats: ( -0.678699 -0.079553 0.605960 )
set Point3 with floats: ( -0.633147 0.435875 -0.046627 )
set Point3 with floats: ( -0.716491 0.267317 -0.514874 )
set Quat with floats: ( -0.751700 0.742959 -0.793180 0.508814 )
set Quat with floats: ( -0.238839 0.113471 -0.843523 -0.245250 )
set Quat with floats: ( 0.250368 0.579243 -0.157280 0.648487 )
set Quat with floats: ( 0.103833 0.456401 -0.022372 -0.475631 )
set Matrix3 columns:
( 0.137637 -0.336303 -0.823874 )
( -0.111879 -0.146740 0.349776 )
( -0.929543 0.165140 0.174872 )
set Matrix3 columns:
( -0.528584 0.137637 -0.336303 )
( 0.489292 -0.111879 -0.146740 )
( 0.916708 -0.929543 0.165140 )
set Matrix4 columns:
( 0.728511 -0.996308 0.517122 -0.171933 )
( -0.851140 0.433229 0.257921 -0.214078 )
( 0.079620 -0.892684 0.862028 -0.604841 )
( -0.234370 -0.957911 0.095881 -0.383831 )
set Matrix4 columns:
( -0.171933 0.728511 -0.996308 0.517122 )
( -0.214078 -0.851140 0.433229 0.257921 )
( -0.604841 0.079620 -0.892684 0.862028 )
( -0.383831 -0.234370 -0.957911 0.095881 )
set Transform3 columns:
( 0.137637 -0.336303 -0.823874 -0.528584 )
( -0.111879 -0.146740 0.349776 0.489292 )
( -0.929543 0.165140 0.174872 0.916708 )
set Transform3 columns:
( -0.528584 0.137637 -0.336303 -0.823874 )
( 0.489292 -0.111879 -0.146740 0.349776 )
( 0.916708 -0.929543 0.165140 0.174872 )
Matrix3 + Matrix3:
( -0.390948 -0.198667 -1.160178 )
( 0.377413 -0.258619 0.203036 )
( -0.012835 -0.764402 0.340013 )
Matrix3 - Matrix3:
( 0.666221 -0.473940 -0.487571 )
( -0.601171 -0.034861 0.496517 )
( -1.846250 1.094683 0.009732 )
-Matrix3:
( -0.137637 0.336303 0.823874 )
( 0.111879 0.146740 -0.349776 )
( 0.929543 -0.165140 -0.174872 )
Matrix3 * float:
( -0.000575 0.001405 0.003442 )
( 0.000467 0.000613 -0.001461 )
( 0.003884 -0.000690 -0.000731 )
float * Matrix3:
( -0.002872 0.007017 0.017190 )
( 0.002334 0.003062 -0.007298 )
( 0.019395 -0.003446 -0.003649 )
Matrix3 * Vector3: ( 0.822395 -0.324114 -0.308966 )
Matrix3 * Matrix3:
( -0.992555 0.822395 -0.132993 )
( 0.307981 -0.324114 0.116920 )
( 0.732450 -0.308966 0.317254 )
set Vector3 with floats: ( -0.016997 0.699144 0.837796 )
set Vector3 with floats: ( -0.276082 0.091582 0.209064 )
set Vector3 with floats: ( 0.219317 -0.118359 0.413442 )
set Vector3 with floats: ( -0.567698 0.531358 -0.387226 )
set Vector4 with floats: ( 0.572490 -0.820417 0.797191 0.867178 )
set Vector4 with floats: ( 0.934764 0.237092 -0.866162 -0.773939 )
set Vector4 with floats: ( 0.261311 -0.851570 0.114814 -0.531592 )
set Vector4 with floats: ( 0.223925 0.869105 0.143405 0.148518 )
set Point3 with floats: ( -0.071136 -0.758292 -0.527633 )
set Point3 with floats: ( 0.997215 0.114440 0.727558 )
set Point3 with floats: ( -0.425760 0.459888 0.642516 )
set Point3 with floats: ( -0.022534 0.186095 -0.775679 )
set Quat with floats: ( -0.683401 0.398134 0.189642 0.765986 )
set Quat with floats: ( -0.137795 -0.579844 -0.635647 0.374970 )
set Quat with floats: ( -0.563750 -0.471075 -0.553800 -0.014688 )
set Quat with floats: ( -0.464365 -0.107890 -0.527503 -0.406423 )
set Matrix3 columns:
( -0.016997 -0.276082 0.219317 )
( 0.699144 0.091582 -0.118359 )
( 0.837796 0.209064 0.413442 )
set Matrix3 columns:
( -0.567698 -0.016997 -0.276082 )
( 0.531358 0.699144 0.091582 )
( -0.387226 0.837796 0.209064 )
set Matrix4 columns:
( 0.572490 0.934764 0.261311 0.223925 )
( -0.820417 0.237092 -0.851570 0.869105 )
( 0.797191 -0.866162 0.114814 0.143405 )
( 0.867178 -0.773939 -0.531592 0.148518 )
set Matrix4 columns:
( 0.223925 0.572490 0.934764 0.261311 )
( 0.869105 -0.820417 0.237092 -0.851570 )
( 0.143405 0.797191 -0.866162 0.114814 )
( 0.148518 0.867178 -0.773939 -0.531592 )
set Transform3 columns:
( -0.016997 -0.276082 0.219317 -0.567698 )
( 0.699144 0.091582 -0.118359 0.531358 )
( 0.837796 0.209064 0.413442 -0.387226 )
set Transform3 columns:
( -0.567698 -0.016997 -0.276082 0.219317 )
( 0.531358 0.699144 0.091582 -0.118359 )
( -0.387226 0.837796 0.209064 0.413442 )
Matrix4 + Matrix4:
( 0.796414 1.507254 1.196075 0.485235 )
( 0.048687 -0.583325 -0.614477 0.017535 )
( 0.940596 -0.068971 -0.751347 0.258219 )
( 1.015695 0.093239 -1.305531 -0.383075 )
Matrix4 - Matrix4:
( 0.348565 0.362275 -0.673454 -0.037386 )
( -1.689522 1.057509 -1.088662 1.720674 )
( 0.653787 -1.663353 0.980976 0.028590 )
( 0.718660 -1.641117 0.242347 0.680110 )
-Matrix4:
( -0.572490 -0.934764 -0.261311 -0.223925 )
( 0.820417 -0.237092 0.851570 -0.869105 )
( -0.797191 0.866162 -0.114814 -0.143405 )
( -0.867178 0.773939 0.531592 -0.148518 )
Matrix4 * float:
( 0.172469 0.281608 0.078723 0.067460 )
( -0.247160 0.071427 -0.256545 0.261827 )
( 0.240163 -0.260941 0.034589 0.043202 )
( 0.261247 -0.233158 -0.160148 0.044743 )
float * Matrix4:
( 0.285975 0.466942 0.130532 0.111857 )
( -0.409822 0.118434 -0.425383 0.434143 )
( 0.398220 -0.432673 0.057353 0.071635 )
( 0.433180 -0.386605 -0.265545 0.074189 )
Matrix4 * Vector4: ( -0.036655 -0.589390 1.382884 0.836413 )
Matrix4 * Vector3: ( 0.862729 -0.533736 -0.522930 -1.001200 )
Matrix4 * Point3: ( -0.663500 1.196998 0.682919 0.954187 )
Matrix4 * Matrix4:
( 1.011332 -0.036655 0.357127 -0.735454 )
( 0.029304 -0.589390 -0.645721 -0.976066 )
( -0.536511 1.382884 0.329392 0.882861 )
( -0.532626 0.836413 0.972614 0.745680 )
Matrix4 * Transform3:
( 0.070508 0.862729 -0.017816 0.346880 )
( 0.921479 -0.533736 0.070183 0.309037 )
( -0.957265 -0.522930 -0.275411 0.468230 )
( -0.697687 -1.001200 -0.421428 0.210525 )
set Vector3 with floats: ( 0.385180 -0.150218 0.519112 )
set Vector3 with floats: ( -0.203209 -0.252017 0.282194 )
set Vector3 with floats: ( 0.067637 0.798376 0.310782 )
set Vector3 with floats: ( 0.861334 -0.980345 -0.655106 )
set Vector4 with floats: ( 0.286765 0.532078 0.352671 0.540977 )
set Vector4 with floats: ( 0.510961 0.791871 -0.564379 0.273199 )
set Vector4 with floats: ( 0.194378 0.244636 -0.269608 -0.858162 )
set Vector4 with floats: ( -0.495023 -0.277798 -0.032740 0.007412 )
set Point3 with floats: ( -0.420178 -0.522577 0.324972 )
set Point3 with floats: ( 0.795389 0.342900 -0.913636 )
set Point3 with floats: ( 0.675222 0.144053 -0.632329 )
set Point3 with floats: ( -0.947120 -0.049367 0.126333 )
set Quat with floats: ( -0.664206 0.220879 0.284219 -0.387216 )
set Quat with floats: ( 0.913568 0.531906 0.271995 -0.862601 )
set Quat with floats: ( -0.738694 0.514248 -0.039363 0.429390 )
set Quat with floats: ( -0.769469 0.281336 -0.203301 0.412586 )
set Matrix3 columns:
( 0.385180 -0.203209 0.067637 )
( -0.150218 -0.252017 0.798376 )
( 0.519112 0.282194 0.310782 )
set Matrix3 columns:
( 0.861334 0.385180 -0.203209 )
( -0.980345 -0.150218 -0.252017 )
( -0.655106 0.519112 0.282194 )
set Matrix4 columns:
( 0.286765 0.510961 0.194378 -0.495023 )
( 0.532078 0.791871 0.244636 -0.277798 )
( 0.352671 -0.564379 -0.269608 -0.032740 )
( 0.540977 0.273199 -0.858162 0.007412 )
set Matrix4 columns:
( -0.495023 0.286765 0.510961 0.194378 )
( -0.277798 0.532078 0.791871 0.244636 )
( -0.032740 0.352671 -0.564379 -0.269608 )
( 0.007412 0.540977 0.273199 -0.858162 )
set Transform3 columns:
( 0.385180 -0.203209 0.067637 0.861334 )
( -0.150218 -0.252017 0.798376 -0.980345 )
( 0.519112 0.282194 0.310782 -0.655106 )
set Transform3 columns:
( 0.861334 0.385180 -0.203209 0.067637 )
( -0.980345 -0.150218 -0.252017 0.798376 )
( -0.655106 0.519112 0.282194 0.310782 )
Transform3 * Vector3: ( 0.214000 0.394443 0.318891 )
Transform3 * Point3: ( 0.827662 -0.526078 -0.919697 )
Transform3 * Transform3:
( 0.486673 0.214000 -0.007973 0.746170 )
( -0.405345 0.394443 0.319335 -0.943589 )
( -0.033113 0.318891 -0.088905 -0.298112 )
__end__

View File

@@ -0,0 +1,433 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector3 tmpV3_0;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 );
vmathSoaM3Prints( &tmpM3_0, "Matrix3 + Matrix3" );
vmathSoaM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 );
vmathSoaM3Prints( &tmpM3_1, "Matrix3 - Matrix3" );
vmathSoaM3Neg( &tmpM3_2, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_2, "-Matrix3" );
vmathSoaM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() );
vmathSoaM3Prints( &tmpM3_3, "Matrix3 * float" );
vmathSoaM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() );
vmathSoaM3Prints( &tmpM3_4, "float * Matrix3" );
vmathSoaM3MulV3( &tmpV3_0, &a_Matrix3, &a_Vector3 );
vmathSoaV3Prints( &tmpV3_0, "Matrix3 * Vector3" );
vmathSoaM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 );
vmathSoaM3Prints( &tmpM3_5, "Matrix3 * Matrix3" );
}
void
Matrix4_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 );
vmathSoaM4Prints( &tmpM4_0, "Matrix4 + Matrix4" );
vmathSoaM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 );
vmathSoaM4Prints( &tmpM4_1, "Matrix4 - Matrix4" );
vmathSoaM4Neg( &tmpM4_2, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_2, "-Matrix4" );
vmathSoaM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() );
vmathSoaM4Prints( &tmpM4_3, "Matrix4 * float" );
vmathSoaM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() );
vmathSoaM4Prints( &tmpM4_4, "float * Matrix4" );
vmathSoaM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 );
vmathSoaV4Prints( &tmpV4_0, "Matrix4 * Vector4" );
vmathSoaM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 );
vmathSoaV4Prints( &tmpV4_1, "Matrix4 * Vector3" );
vmathSoaM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 );
vmathSoaV4Prints( &tmpV4_2, "Matrix4 * Point3" );
vmathSoaM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 );
vmathSoaM4Prints( &tmpM4_5, "Matrix4 * Matrix4" );
vmathSoaM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 );
vmathSoaM4Prints( &tmpM4_6, "Matrix4 * Transform3" );
}
void
Transform3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector3 tmpV3_0;
VmathSoaPoint3 tmpP3_0;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaT3MulV3( &tmpV3_0, &a_Transform3, &a_Vector3 );
vmathSoaV3Prints( &tmpV3_0, "Transform3 * Vector3" );
vmathSoaT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 );
vmathSoaP3Prints( &tmpP3_0, "Transform3 * Point3" );
vmathSoaT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 );
vmathSoaT3Prints( &tmpT3_0, "Transform3 * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,410 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Soa;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" );
print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" );
print( ( -a_Matrix3 ), "-Matrix3" );
print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" );
print( ( randfloat() * a_Matrix3 ), "float * Matrix3" );
print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" );
print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" );
print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" );
print( ( -a_Matrix4 ), "-Matrix4" );
print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" );
print( ( randfloat() * a_Matrix4 ), "float * Matrix4" );
print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" );
print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" );
print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" );
print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" );
print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" );
print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" );
print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,567 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 );
vmathM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" );
vmathM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 );
vmathM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" );
vmathM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 );
vmathM3Prints( &tmpM3_2, "mulPerElem Matrix3" );
vmathM3AbsPerElem( &tmpM3_3, &a_Matrix3 );
vmathM3Prints( &tmpM3_3, "absPerElem Matrix3" );
vmathM3Transpose( &tmpM3_4, &a_Matrix3 );
vmathM3Prints( &tmpM3_4, "transpose Matrix3" );
vmathM3Inverse( &tmpM3_5, &a_Matrix3 );
vmathM3Prints( &tmpM3_5, "inverse Matrix3" );
vmathM3Inverse( &tmpM3_6, &a_Matrix3 );
vmathM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 );
vmathM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" );
printf("%f\n", getfloat(vmathM3Determinant( &a_Matrix3 )) );
vmathV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 );
vmathM3Prints( &tmpM3_8, "outer Vector3" );
vmathV3RowMul( &tmpV3_8, &a_Vector3, &a_Matrix3 );
vmathV3Prints( &tmpV3_8, "rowMul Vector3" );
vmathV3CrossMatrix( &tmpM3_9, &a_Vector3 );
vmathM3Prints( &tmpM3_9, "crossMatrix" );
vmathV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 );
vmathM3Prints( &tmpM3_10, "crossMatrixMul" );
}
void
Matrix4_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3;
VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7;
VmathMatrix3 tmpM3_0;
VmathMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7;
VmathVector4 tmpV4_0;
VmathQuat tmpQ_0;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 );
vmathM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" );
vmathM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 );
vmathM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" );
vmathM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 );
vmathM4Prints( &tmpM4_2, "mulPerElem Matrix4" );
vmathM4AbsPerElem( &tmpM4_3, &a_Matrix4 );
vmathM4Prints( &tmpM4_3, "absPerElem Matrix4" );
vmathM4Transpose( &tmpM4_4, &a_Matrix4 );
vmathM4Prints( &tmpM4_4, "transpose Matrix4" );
vmathM4Inverse( &tmpM4_5, &a_Matrix4 );
vmathM4Prints( &tmpM4_5, "inverse Matrix4" );
vmathM4Inverse( &tmpM4_6, &a_Matrix4 );
vmathM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 );
vmathM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" );
vmathV4MakeFromElems( &tmpV4_0, 0.0f, 0.0f, 0.0f, 1.0f );
vmathM4SetRow( &a_Matrix4, 3, &tmpV4_0 );
vmathQNormalize( &tmpQ_0, &a_Quat );
vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 );
vmathM4SetUpper3x3( &a_Matrix4, &tmpM3_0 );
vmathM4AffineInverse( &tmpM4_8, &a_Matrix4 );
vmathM4Prints( &tmpM4_8, "affineInverse Matrix4" );
vmathM4AffineInverse( &tmpM4_9, &a_Matrix4 );
vmathM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 );
vmathM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" );
vmathM4OrthoInverse( &tmpM4_11, &a_Matrix4 );
vmathM4Prints( &tmpM4_11, "orthoInverse Matrix4" );
vmathM4OrthoInverse( &tmpM4_12, &a_Matrix4 );
vmathM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 );
vmathM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" );
printf("%f\n", getfloat(vmathM4Determinant( &a_Matrix4 )) );
vmathV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 );
vmathM4Prints( &tmpM4_14, "outer Vector4" );
}
void
Transform3_methods_test()
{
VmathMatrix3 a_Matrix3, b_Matrix3;
VmathMatrix4 a_Matrix4, b_Matrix4;
VmathTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6;
VmathMatrix3 tmpM3_0;
VmathTransform3 tmpT3_7, tmpT3_8, tmpT3_9;
VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathVector4 tmpV4;
VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7;
VmathQuat tmpQ_0;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad );
vmathV4GetXYZ( &a_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad );
vmathV4GetXYZ( &b_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad );
vmathV4GetXYZ( &c_Vector3, &tmpV4 );
vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad );
vmathV4GetXYZ( &d_Vector3, &tmpV4 );
vmathV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathV3MakeFromP3( &tmpV3_0, &a_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad );
vmathV4GetXYZ( &tmpV3_1, &tmpV4 );
vmathP3MakeFromV3( &a_Point3, &tmpV3_1 );
vmathV3MakeFromP3( &tmpV3_2, &b_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad );
vmathV4GetXYZ( &tmpV3_3, &tmpV4 );
vmathP3MakeFromV3( &b_Point3, &tmpV3_3 );
vmathV3MakeFromP3( &tmpV3_4, &c_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad );
vmathV4GetXYZ( &tmpV3_5, &tmpV4 );
vmathP3MakeFromV3( &c_Point3, &tmpV3_5 );
vmathV3MakeFromP3( &tmpV3_6, &d_Point3 );
vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad );
vmathV4GetXYZ( &tmpV3_7, &tmpV4 );
vmathP3MakeFromV3( &d_Point3, &tmpV3_7 );
vmathP3Prints( &a_Point3, "set Point3 with floats" );
vmathP3Prints( &b_Point3, "set Point3 with floats" );
vmathP3Prints( &c_Point3, "set Point3 with floats" );
vmathP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathQPrints( &a_Quat, "set Quat with floats" );
vmathQPrints( &b_Quat, "set Quat with floats" );
vmathQPrints( &c_Quat, "set Quat with floats" );
vmathQPrints( &d_Quat, "set Quat with floats" );
vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathT3Prints( &a_Transform3, "set Transform3 columns" );
vmathT3Prints( &b_Transform3, "set Transform3 columns" );
vmathT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 );
vmathT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" );
vmathT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 );
vmathT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" );
vmathT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 );
vmathT3Prints( &tmpT3_2, "mulPerElem Transform3" );
vmathT3AbsPerElem( &tmpT3_3, &a_Transform3 );
vmathT3Prints( &tmpT3_3, "absPerElem Transform3" );
vmathT3Inverse( &tmpT3_4, &a_Transform3 );
vmathT3Prints( &tmpT3_4, "inverse Transform3" );
vmathT3Inverse( &tmpT3_5, &a_Transform3 );
vmathT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 );
vmathT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" );
vmathQNormalize( &tmpQ_0, &a_Quat );
vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 );
vmathT3SetUpper3x3( &a_Transform3, &tmpM3_0 );
vmathT3OrthoInverse( &tmpT3_7, &a_Transform3 );
vmathT3Prints( &tmpT3_7, "orthoInverse Transform3" );
vmathT3OrthoInverse( &tmpT3_8, &a_Transform3 );
vmathT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 );
vmathT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,492 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_AOS_TEST
#include "vectormath_aos.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Aos;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" );
print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" );
print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" );
print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" );
print( transpose( a_Matrix3 ), "transpose Matrix3" );
print( inverse( a_Matrix3 ), "inverse Matrix3" );
print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" );
printf("%f\n", getfloat(determinant( a_Matrix3 )) );
print( outer( a_Vector3, b_Vector3 ), "outer Vector3" );
print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" );
print( crossMatrix( a_Vector3 ), "crossMatrix" );
print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" );
print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" );
print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" );
print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" );
print( transpose( a_Matrix4 ), "transpose Matrix4" );
print( inverse( a_Matrix4 ), "inverse Matrix4" );
print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" );
a_Matrix4.setRow( 3, Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) );
print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" );
print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" );
print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" );
print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" );
printf("%f\n", getfloat(determinant( a_Matrix4 )) );
print( outer( a_Vector4, b_Vector4 ), "outer Vector4" );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
Vector4 tmpV4;
float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad;
// set a pad value to detect invalid use of padding.
// this will be nan for scalar/ppu implementations, max. float for spu
union { float f; unsigned int u; } tmp;
tmp.u = 0x7fffffff;
pad = tmp.f;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( a_Vector3, pad );
a_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( b_Vector3, pad );
b_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( c_Vector3, pad );
c_Vector3 = tmpV4.getXYZ( );
tmpV4 = Vector4( d_Vector3, pad );
d_Vector3 = tmpV4.getXYZ( );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
tmpV4 = Vector4( Vector3( a_Point3 ), pad );
a_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( b_Point3 ), pad );
b_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( c_Point3 ), pad );
c_Point3 = Point3( tmpV4.getXYZ( ) );
tmpV4 = Vector4( Vector3( d_Point3 ), pad );
d_Point3 = Point3( tmpV4.getXYZ( ) );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" );
print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" );
print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" );
print( absPerElem( a_Transform3 ), "absPerElem Transform3" );
print( inverse( a_Transform3 ), "inverse Transform3" );
print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" );
a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) );
print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" );
print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,524 @@
set Vector3 with floats: ( -0.658344 0.499804 -0.807257 )
set Vector3 with floats: ( 0.740930 0.154607 0.571599 )
set Vector3 with floats: ( 0.384388 -0.262467 0.747808 )
set Vector3 with floats: ( 0.490190 -0.107908 -0.292544 )
set Vector4 with floats: ( 0.465039 -0.479556 -0.211412 0.553580 )
set Vector4 with floats: ( 0.690070 0.151576 0.431077 -0.833992 )
set Vector4 with floats: ( -0.088350 -0.780106 0.090456 -0.218627 )
set Vector4 with floats: ( 0.137171 0.918133 0.735438 -0.673621 )
set Point3 with floats: ( -0.448982 -0.479278 0.848189 )
set Point3 with floats: ( -0.128155 0.578922 -0.744766 )
set Point3 with floats: ( -0.835589 0.881284 -0.948850 )
set Point3 with floats: ( -0.691578 -0.235635 -0.690527 )
set Quat with floats: ( 0.058667 0.753697 -0.138777 -0.472188 )
set Quat with floats: ( -0.372811 0.540183 -0.785218 0.542085 )
set Quat with floats: ( 0.410391 -0.562721 0.523588 -0.176574 )
set Quat with floats: ( 0.297654 0.859913 0.004837 0.374881 )
set Matrix3 columns:
( -0.658344 0.740930 0.384388 )
( 0.499804 0.154607 -0.262467 )
( -0.807257 0.571599 0.747808 )
set Matrix3 columns:
( 0.490190 -0.658344 0.740930 )
( -0.107908 0.499804 0.154607 )
( -0.292544 -0.807257 0.571599 )
set Matrix4 columns:
( 0.465039 0.690070 -0.088350 0.137171 )
( -0.479556 0.151576 -0.780106 0.918133 )
( -0.211412 0.431077 0.090456 0.735438 )
( 0.553580 -0.833992 -0.218627 -0.673621 )
set Matrix4 columns:
( 0.137171 0.465039 0.690070 -0.088350 )
( 0.918133 -0.479556 0.151576 -0.780106 )
( 0.735438 -0.211412 0.431077 0.090456 )
( -0.673621 0.553580 -0.833992 -0.218627 )
set Transform3 columns:
( -0.658344 0.740930 0.384388 0.490190 )
( 0.499804 0.154607 -0.262467 -0.107908 )
( -0.807257 0.571599 0.747808 -0.292544 )
set Transform3 columns:
( 0.490190 -0.658344 0.740930 0.384388 )
( -0.107908 0.499804 0.154607 -0.262467 )
( -0.292544 -0.807257 0.571599 0.747808 )
appendScale Matrix3 Vector3:
( 0.433417 0.370320 -0.310300 )
( -0.329043 0.077273 0.211879 )
( 0.531453 0.285687 -0.603673 )
prependScale Vector3 Matrix3:
( 0.433417 -0.487787 -0.253060 )
( 0.249804 0.077273 -0.131182 )
( 0.651663 -0.461427 -0.603673 )
mulPerElem Matrix3:
( -0.322714 -0.487787 0.284805 )
( -0.053933 0.077273 -0.040579 )
( 0.236158 -0.461427 0.427446 )
absPerElem Matrix3:
( 0.658344 0.740930 0.384388 )
( 0.499804 0.154607 0.262467 )
( 0.807257 0.571599 0.747808 )
transpose Matrix3:
( -0.658344 0.499804 -0.807257 )
( 0.740930 0.154607 0.571599 )
( 0.384388 -0.262467 0.747808 )
inverse Matrix3:
( -1.938491 2.439935 1.852797 )
( 1.181290 1.328230 -0.141021 )
( -2.995533 1.618649 3.445122 )
inverse(Matrix3) * Matrix3:
( 1.000000 0.000000 0.000000 )
( 0.000000 1.000000 -0.000000 )
( 0.000000 -0.000000 1.000000 )
-0.137036
outer Vector3:
( -0.487787 -0.101785 -0.376308 )
( 0.370320 0.077273 0.285687 )
( -0.598121 -0.124808 -0.461427 )
rowMul Vector3: ( 1.334884 -0.871941 -0.987915 )
crossMatrix:
( 0.000000 0.807257 0.499804 )
( -0.807257 0.000000 0.658344 )
( -0.499804 -0.658344 0.000000 )
crossMatrixMul:
( 0.000000 0.410495 0.161879 )
( 0.000000 -0.221813 0.182015 )
( 0.000000 -0.472105 -0.019325 )
set Vector3 with floats: ( -0.127818 0.216602 0.153117 )
set Vector3 with floats: ( 0.265243 -0.073149 0.264488 )
set Vector3 with floats: ( -0.723410 0.921523 -0.711250 )
set Vector3 with floats: ( -0.106634 -0.350831 0.905168 )
set Vector4 with floats: ( -0.283632 -0.203584 -0.797437 0.910171 )
set Vector4 with floats: ( 0.969234 0.151940 0.731827 -0.700248 )
set Vector4 with floats: ( 0.818301 0.302505 -0.872278 0.909999 )
set Vector4 with floats: ( 0.932526 0.571087 0.610330 0.142507 )
set Point3 with floats: ( -0.434829 0.925102 0.158954 )
set Point3 with floats: ( -0.126283 -0.249128 0.846815 )
set Point3 with floats: ( -0.942601 0.537720 0.446214 )
set Point3 with floats: ( 0.181939 -0.148223 0.284286 )
set Quat with floats: ( 0.493525 -0.861963 -0.893410 0.548627 )
set Quat with floats: ( 0.407007 -0.757467 -0.393126 -0.850984 )
set Quat with floats: ( 0.375720 -0.270088 0.458888 -0.610828 )
set Quat with floats: ( -0.690816 -0.676415 0.664466 0.101874 )
set Matrix3 columns:
( -0.127818 0.265243 -0.723410 )
( 0.216602 -0.073149 0.921523 )
( 0.153117 0.264488 -0.711250 )
set Matrix3 columns:
( -0.106634 -0.127818 0.265243 )
( -0.350831 0.216602 -0.073149 )
( 0.905168 0.153117 0.264488 )
set Matrix4 columns:
( -0.283632 0.969234 0.818301 0.932526 )
( -0.203584 0.151940 0.302505 0.571087 )
( -0.797437 0.731827 -0.872278 0.610330 )
( 0.910171 -0.700248 0.909999 0.142507 )
set Matrix4 columns:
( 0.932526 -0.283632 0.969234 0.818301 )
( 0.571087 -0.203584 0.151940 0.302505 )
( 0.610330 -0.797437 0.731827 -0.872278 )
( 0.142507 0.910171 -0.700248 0.909999 )
set Transform3 columns:
( -0.127818 0.265243 -0.723410 -0.106634 )
( 0.216602 -0.073149 0.921523 -0.350831 )
( 0.153117 0.264488 -0.711250 0.905168 )
set Transform3 columns:
( -0.106634 -0.127818 0.265243 -0.723410 )
( -0.350831 0.216602 -0.073149 0.921523 )
( 0.905168 0.153117 0.264488 -0.711250 )
appendScale Matrix4 Vector3:
( 0.036253 0.209938 0.125296 0.932526 )
( 0.026022 0.032911 0.046319 0.571087 )
( 0.101927 0.158515 -0.133561 0.610330 )
( -0.116336 -0.151675 0.139337 0.142507 )
prependScale Vector3 Matrix4:
( 0.036253 -0.123886 -0.104594 -0.119194 )
( -0.044097 0.032911 0.065523 0.123698 )
( -0.122101 0.112055 -0.133561 0.093452 )
( 0.910171 -0.700248 0.909999 0.142507 )
mulPerElem Matrix4:
( -0.264494 -0.274906 0.793125 0.763086 )
( -0.116264 -0.030933 0.045963 0.172757 )
( -0.486699 -0.583586 -0.638357 -0.532377 )
( 0.129706 -0.637346 -0.637225 0.129682 )
absPerElem Matrix4:
( 0.283632 0.969234 0.818301 0.932526 )
( 0.203584 0.151940 0.302505 0.571087 )
( 0.797437 0.731827 0.872278 0.610330 )
( 0.910171 0.700248 0.909999 0.142507 )
transpose Matrix4:
( -0.283632 -0.203584 -0.797437 0.910171 )
( 0.969234 0.151940 0.731827 -0.700248 )
( 0.818301 0.302505 -0.872278 0.909999 )
( 0.932526 0.571087 0.610330 0.142507 )
inverse Matrix4:
( 0.756962 -3.392262 1.563321 1.945501 )
( 1.235862 -2.616357 0.503558 0.241096 )
( 0.221503 1.293015 -1.354804 -0.828755 )
( -0.176291 0.552941 1.140966 1.068388 )
inverse(Matrix4) * Matrix4:
( 1.000000 0.000000 -0.000000 0.000000 )
( -0.000000 1.000000 -0.000000 -0.000000 )
( 0.000000 -0.000000 1.000000 -0.000000 )
( -0.000000 0.000000 0.000000 1.000000 )
affineInverse Matrix4:
( -0.477821 -0.877922 0.030662 0.928236 )
( 0.062087 0.001066 0.998070 -0.667659 )
( -0.876260 0.478803 0.053999 0.510740 )
( 0.000000 0.000000 0.000000 1.000000 )
affineInverse(Matrix4) * Matrix4:
( 1.000000 0.000000 -0.000000 0.000000 )
( 0.000000 1.000000 0.000000 0.000000 )
( -0.000000 0.000000 1.000000 0.000000 )
( 0.000000 0.000000 0.000000 1.000000 )
orthoInverse Matrix4:
( -0.477822 -0.877922 0.030662 0.928237 )
( 0.062087 0.001066 0.998070 -0.667659 )
( -0.876260 0.478803 0.053999 0.510740 )
( 0.000000 0.000000 0.000000 1.000000 )
orthoInverse(Matrix4) * Matrix4:
( 1.000000 0.000000 0.000000 0.000000 )
( 0.000000 1.000000 -0.000000 -0.000000 )
( 0.000000 -0.000000 1.000000 -0.000000 )
( 0.000000 0.000000 0.000000 1.000000 )
1.000000
outer Vector4:
( -0.274906 -0.043095 -0.207570 0.198613 )
( -0.197320 -0.030933 -0.148988 0.142559 )
( -0.772903 -0.121163 -0.583586 0.558404 )
( 0.882169 0.138292 0.666089 -0.637346 )
set Vector3 with floats: ( -0.365714 0.055473 -0.133556 )
set Vector3 with floats: ( -0.572643 0.459209 -0.997261 )
set Vector3 with floats: ( 0.172409 -0.045124 0.879716 )
set Vector3 with floats: ( 0.524317 -0.744532 -0.970444 )
set Vector4 with floats: ( -0.000013 0.689543 0.704297 -0.817983 )
set Vector4 with floats: ( 0.715505 0.577868 0.156952 -0.801022 )
set Vector4 with floats: ( 0.656335 0.494393 0.816743 0.024285 )
set Vector4 with floats: ( 0.769132 0.923895 0.133022 -0.052219 )
set Point3 with floats: ( -0.164886 0.300690 0.760403 )
set Point3 with floats: ( 0.171869 -0.554976 0.998693 )
set Point3 with floats: ( -0.681641 0.391195 0.403059 )
set Point3 with floats: ( 0.972411 0.297195 0.309761 )
set Quat with floats: ( 0.688408 0.363540 0.940297 -0.336683 )
set Quat with floats: ( 0.600164 -0.681272 0.726558 0.205513 )
set Quat with floats: ( -0.160082 0.962714 0.737794 -0.071926 )
set Quat with floats: ( -0.506313 0.689277 0.686485 0.473013 )
set Matrix3 columns:
( -0.365714 -0.572643 0.172409 )
( 0.055473 0.459209 -0.045124 )
( -0.133556 -0.997261 0.879716 )
set Matrix3 columns:
( 0.524317 -0.365714 -0.572643 )
( -0.744532 0.055473 0.459209 )
( -0.970444 -0.133556 -0.997261 )
set Matrix4 columns:
( -0.000013 0.715505 0.656335 0.769132 )
( 0.689543 0.577868 0.494393 0.923895 )
( 0.704297 0.156952 0.816743 0.133022 )
( -0.817983 -0.801022 0.024285 -0.052219 )
set Matrix4 columns:
( 0.769132 -0.000013 0.715505 0.656335 )
( 0.923895 0.689543 0.577868 0.494393 )
( 0.133022 0.704297 0.156952 0.816743 )
( -0.052219 -0.817983 -0.801022 0.024285 )
set Transform3 columns:
( -0.365714 -0.572643 0.172409 0.524317 )
( 0.055473 0.459209 -0.045124 -0.744532 )
( -0.133556 -0.997261 0.879716 -0.970444 )
set Transform3 columns:
( 0.524317 -0.365714 -0.572643 0.172409 )
( -0.744532 0.055473 0.459209 -0.045124 )
( -0.970444 -0.133556 -0.997261 0.879716 )
appendScale Transform3 Vector3:
( 0.133747 -0.031766 -0.023026 0.524317 )
( -0.020287 0.025474 0.006027 -0.744532 )
( 0.048843 -0.055321 -0.117491 -0.970444 )
prependScale Vector3 Transform3:
( 0.133747 0.209424 -0.063052 -0.191750 )
( 0.003077 0.025474 -0.002503 -0.041301 )
( 0.017837 0.133190 -0.117491 0.129609 )
mulPerElem Transform3:
( -0.191750 0.209424 -0.098729 0.090397 )
( -0.041301 0.025474 -0.020721 0.033596 )
( 0.129609 0.133190 -0.877307 -0.853715 )
absPerElem Transform3:
( 0.365714 0.572643 0.172409 0.524317 )
( 0.055473 0.459209 0.045124 0.744532 )
( 0.133556 0.997261 0.879716 0.970444 )
inverse Transform3:
( -3.394501 -3.137797 0.504313 -0.066988 )
( 0.404474 2.824531 0.065611 1.954553 )
( -0.056825 2.725566 1.287672 3.308679 )
inverse(Transform3) * Transform3:
( 1.000000 -0.000000 0.000000 0.000000 )
( 0.000000 1.000000 -0.000000 -0.000000 )
( -0.000000 -0.000000 1.000000 0.000000 )
orthoInverse Transform3:
( -0.267562 -0.082713 0.959984 1.010315 )
( 0.706975 -0.693789 0.137268 -0.754017 )
( 0.654673 0.715412 0.244108 0.426284 )
orthoInverse(Transform3) * Transform3:
( 1.000000 0.000000 0.000000 -0.000000 )
( 0.000000 1.000000 0.000000 -0.000000 )
( 0.000000 0.000000 1.000000 -0.000000 )
set Vector3 with floats: ( -0.735610 -0.046390 0.568674 )
set Vector3 with floats: ( -0.004815 0.137637 -0.111879 )
set Vector3 with floats: ( -0.929543 -0.336303 -0.146740 )
set Vector3 with floats: ( 0.165140 -0.823874 0.349776 )
set Vector4 with floats: ( 0.174872 -0.528584 0.489292 0.916708 )
set Vector4 with floats: ( 0.728511 -0.851140 0.079620 -0.234370 )
set Vector4 with floats: ( -0.996308 0.433229 -0.892684 -0.957911 )
set Vector4 with floats: ( 0.517122 0.257921 0.862028 0.095881 )
set Point3 with floats: ( -0.171933 -0.214078 -0.604841 )
set Point3 with floats: ( -0.383831 -0.581500 0.222183 )
set Point3 with floats: ( -0.256120 -0.678699 -0.079553 )
set Point3 with floats: ( 0.605960 -0.633147 0.435875 )
set Quat with floats: ( -0.046627 -0.716491 0.267317 -0.514874 )
set Quat with floats: ( -0.751700 0.742959 -0.793180 0.508814 )
set Quat with floats: ( -0.238839 0.113471 -0.843523 -0.245250 )
set Quat with floats: ( 0.250368 0.579243 -0.157280 0.648487 )
set Matrix3 columns:
( -0.735610 -0.004815 -0.929543 )
( -0.046390 0.137637 -0.336303 )
( 0.568674 -0.111879 -0.146740 )
set Matrix3 columns:
( 0.165140 -0.735610 -0.004815 )
( -0.823874 -0.046390 0.137637 )
( 0.349776 0.568674 -0.111879 )
set Matrix4 columns:
( 0.174872 0.728511 -0.996308 0.517122 )
( -0.528584 -0.851140 0.433229 0.257921 )
( 0.489292 0.079620 -0.892684 0.862028 )
( 0.916708 -0.234370 -0.957911 0.095881 )
set Matrix4 columns:
( 0.517122 0.174872 0.728511 -0.996308 )
( 0.257921 -0.528584 -0.851140 0.433229 )
( 0.862028 0.489292 0.079620 -0.892684 )
( 0.095881 0.916708 -0.234370 -0.957911 )
set Transform3 columns:
( -0.735610 -0.004815 -0.929543 0.165140 )
( -0.046390 0.137637 -0.336303 -0.823874 )
( 0.568674 -0.111879 -0.146740 0.349776 )
set Transform3 columns:
( 0.165140 -0.735610 -0.004815 -0.929543 )
( -0.823874 -0.046390 0.137637 -0.336303 )
( 0.349776 0.568674 -0.111879 -0.146740 )
appendScale Matrix3 Vector3:
( 0.541123 0.000223 -0.528607 )
( 0.034125 -0.006385 -0.191247 )
( -0.418323 0.005190 -0.083447 )
prependScale Vector3 Matrix3:
( 0.541123 0.003542 0.683781 )
( 0.002152 -0.006385 0.015601 )
( 0.323390 -0.063623 -0.083447 )
mulPerElem Matrix3:
( -0.121479 0.003542 0.004475 )
( 0.038220 -0.006385 -0.046288 )
( 0.198909 -0.063623 0.016417 )
absPerElem Matrix3:
( 0.735610 0.004815 0.929543 )
( 0.046390 0.137637 0.336303 )
( 0.568674 0.111879 0.146740 )
transpose Matrix3:
( -0.735610 -0.046390 0.568674 )
( -0.004815 0.137637 -0.111879 )
( -0.929543 -0.336303 -0.146740 )
inverse Matrix3:
( -0.518959 0.927036 1.162799 )
( -1.777555 5.713095 -1.833313 )
( -0.655903 -0.763218 -0.910706 )
inverse(Matrix3) * Matrix3:
( 1.000000 0.000000 0.000000 )
( -0.000000 1.000000 -0.000000 )
( -0.000000 0.000000 1.000000 )
0.111420
outer Vector3:
( 0.003542 -0.101247 0.082299 )
( 0.000223 -0.006385 0.005190 )
( -0.002738 0.078270 -0.063623 )
rowMul Vector3: ( 0.866665 -0.066466 0.615935 )
crossMatrix:
( 0.000000 -0.568674 -0.046390 )
( 0.568674 0.000000 0.735610 )
( 0.046390 -0.735610 0.000000 )
crossMatrixMul:
( 0.000000 -0.073080 0.198054 )
( 0.000000 -0.085037 -0.636550 )
( 0.000000 -0.101470 0.204267 )
set Vector3 with floats: ( 0.103833 0.456401 -0.022372 )
set Vector3 with floats: ( -0.475631 -0.004178 -0.020865 )
set Vector3 with floats: ( -0.016997 0.699144 0.837796 )
set Vector3 with floats: ( -0.276082 0.091582 0.209064 )
set Vector4 with floats: ( 0.219317 -0.118359 0.413442 -0.567698 )
set Vector4 with floats: ( 0.531358 -0.387226 0.572490 -0.820417 )
set Vector4 with floats: ( 0.797191 0.867178 0.934764 0.237092 )
set Vector4 with floats: ( -0.866162 -0.773939 0.261311 -0.851570 )
set Point3 with floats: ( 0.114814 -0.531592 0.223925 )
set Point3 with floats: ( 0.869105 0.143405 0.148518 )
set Point3 with floats: ( -0.071136 -0.758292 -0.527633 )
set Point3 with floats: ( 0.997215 0.114440 0.727558 )
set Quat with floats: ( -0.425760 0.459888 0.642516 -0.022534 )
set Quat with floats: ( 0.186095 -0.775679 -0.683401 0.398134 )
set Quat with floats: ( 0.189642 0.765986 -0.137795 -0.579844 )
set Quat with floats: ( -0.635647 0.374970 -0.563750 -0.471075 )
set Matrix3 columns:
( 0.103833 -0.475631 -0.016997 )
( 0.456401 -0.004178 0.699144 )
( -0.022372 -0.020865 0.837796 )
set Matrix3 columns:
( -0.276082 0.103833 -0.475631 )
( 0.091582 0.456401 -0.004178 )
( 0.209064 -0.022372 -0.020865 )
set Matrix4 columns:
( 0.219317 0.531358 0.797191 -0.866162 )
( -0.118359 -0.387226 0.867178 -0.773939 )
( 0.413442 0.572490 0.934764 0.261311 )
( -0.567698 -0.820417 0.237092 -0.851570 )
set Matrix4 columns:
( -0.866162 0.219317 0.531358 0.797191 )
( -0.773939 -0.118359 -0.387226 0.867178 )
( 0.261311 0.413442 0.572490 0.934764 )
( -0.851570 -0.567698 -0.820417 0.237092 )
set Transform3 columns:
( 0.103833 -0.475631 -0.016997 -0.276082 )
( 0.456401 -0.004178 0.699144 0.091582 )
( -0.022372 -0.020865 0.837796 0.209064 )
set Transform3 columns:
( -0.276082 0.103833 -0.475631 -0.016997 )
( 0.091582 0.456401 -0.004178 0.699144 )
( 0.209064 -0.022372 -0.020865 0.837796 )
appendScale Matrix4 Vector3:
( 0.022772 0.242513 -0.017835 -0.866162 )
( -0.012290 -0.176730 -0.019401 -0.773939 )
( 0.042929 0.261285 -0.020913 0.261311 )
( -0.058946 -0.374439 -0.005304 -0.851570 )
prependScale Vector3 Matrix4:
( 0.022772 0.055173 0.082775 -0.089936 )
( -0.054019 -0.176730 0.395781 -0.353227 )
( -0.009250 -0.012808 -0.020913 -0.005846 )
( -0.567698 -0.820417 0.237092 -0.851570 )
mulPerElem Matrix4:
( -0.189964 0.116536 0.423594 -0.690497 )
( 0.091603 0.045832 -0.335794 -0.671143 )
( 0.108037 0.236691 0.535143 0.244264 )
( 0.483434 0.465749 -0.194514 -0.201900 )
absPerElem Matrix4:
( 0.219317 0.531358 0.797191 0.866162 )
( 0.118359 0.387226 0.867178 0.773939 )
( 0.413442 0.572490 0.934764 0.261311 )
( 0.567698 0.820417 0.237092 0.851570 )
transpose Matrix4:
( 0.219317 -0.118359 0.413442 -0.567698 )
( 0.531358 -0.387226 0.572490 -0.820417 )
( 0.797191 0.867178 0.934764 0.237092 )
( -0.866162 -0.773939 0.261311 -0.851570 )
inverse Matrix4:
( -0.801304 6.311381 -3.640203 -6.038011 )
( 1.289204 -3.528897 1.571125 2.378011 )
( -0.220138 -0.375260 1.356762 0.981293 )
( -0.769143 -0.912151 1.290834 0.833121 )
inverse(Matrix4) * Matrix4:
( 1.000000 -0.000000 -0.000000 0.000000 )
( 0.000000 1.000000 -0.000000 0.000000 )
( -0.000000 0.000000 1.000000 -0.000000 )
( 0.000000 0.000000 0.000000 1.000000 )
affineInverse Matrix4:
( -0.548992 -0.521721 -0.653005 -0.708658 )
( -0.449878 -0.474001 0.756923 -0.954307 )
( -0.704428 0.709317 0.025512 -0.067847 )
( 0.000000 0.000000 0.000000 1.000000 )
affineInverse(Matrix4) * Matrix4:
( 1.000000 0.000000 0.000000 0.000000 )
( 0.000000 1.000000 -0.000000 0.000000 )
( 0.000000 0.000000 1.000000 -0.000000 )
( 0.000000 0.000000 0.000000 1.000000 )
orthoInverse Matrix4:
( -0.548992 -0.521721 -0.653005 -0.708658 )
( -0.449878 -0.474001 0.756923 -0.954307 )
( -0.704428 0.709317 0.025512 -0.067847 )
( 0.000000 0.000000 0.000000 1.000000 )
orthoInverse(Matrix4) * Matrix4:
( 1.000000 0.000000 0.000000 -0.000000 )
( 0.000000 1.000000 -0.000000 0.000000 )
( 0.000000 -0.000000 1.000000 0.000000 )
( 0.000000 0.000000 0.000000 1.000000 )
1.000000
outer Vector4:
( 0.116536 -0.084925 0.125557 -0.179931 )
( -0.062891 0.045832 -0.067760 0.097104 )
( 0.219686 -0.160095 0.236691 -0.339195 )
( -0.301651 0.219827 -0.325001 0.465749 )
set Vector3 with floats: ( -0.553800 -0.014688 -0.464365 )
set Vector3 with floats: ( -0.107890 -0.527503 -0.406423 )
set Vector3 with floats: ( 0.301261 0.499529 0.385180 )
set Vector3 with floats: ( -0.150218 0.519112 -0.203209 )
set Vector4 with floats: ( -0.252017 0.282194 0.067637 0.798376 )
set Vector4 with floats: ( 0.310782 0.861334 -0.980345 -0.655106 )
set Vector4 with floats: ( 0.286765 0.532078 0.352671 0.540977 )
set Vector4 with floats: ( 0.510961 0.791871 -0.564379 0.273199 )
set Point3 with floats: ( 0.194378 0.244636 -0.269608 )
set Point3 with floats: ( -0.858162 -0.495023 -0.277798 )
set Point3 with floats: ( -0.032740 0.007412 -0.420178 )
set Point3 with floats: ( -0.522577 0.324972 0.795389 )
set Quat with floats: ( 0.342900 -0.913636 0.675222 0.144053 )
set Quat with floats: ( -0.632329 -0.947120 -0.049367 0.126333 )
set Quat with floats: ( -0.664206 0.220879 0.284219 -0.387216 )
set Quat with floats: ( 0.913568 0.531906 0.271995 -0.862601 )
set Matrix3 columns:
( -0.553800 -0.107890 0.301261 )
( -0.014688 -0.527503 0.499529 )
( -0.464365 -0.406423 0.385180 )
set Matrix3 columns:
( -0.150218 -0.553800 -0.107890 )
( 0.519112 -0.014688 -0.527503 )
( -0.203209 -0.464365 -0.406423 )
set Matrix4 columns:
( -0.252017 0.310782 0.286765 0.510961 )
( 0.282194 0.861334 0.532078 0.791871 )
( 0.067637 -0.980345 0.352671 -0.564379 )
( 0.798376 -0.655106 0.540977 0.273199 )
set Matrix4 columns:
( 0.510961 -0.252017 0.310782 0.286765 )
( 0.791871 0.282194 0.861334 0.532078 )
( -0.564379 0.067637 -0.980345 0.352671 )
( 0.273199 0.798376 -0.655106 0.540977 )
set Transform3 columns:
( -0.553800 -0.107890 0.301261 -0.150218 )
( -0.014688 -0.527503 0.499529 0.519112 )
( -0.464365 -0.406423 0.385180 -0.203209 )
set Transform3 columns:
( -0.150218 -0.553800 -0.107890 0.301261 )
( 0.519112 -0.014688 -0.527503 0.499529 )
( -0.203209 -0.464365 -0.406423 0.385180 )
appendScale Transform3 Vector3:
( 0.306694 0.001585 -0.139895 -0.150218 )
( 0.008134 0.007748 -0.231964 0.519112 )
( 0.257165 0.005970 -0.178864 -0.203209 )
prependScale Vector3 Transform3:
( 0.306694 0.059749 -0.166838 0.083191 )
( 0.000216 0.007748 -0.007337 -0.007625 )
( 0.215635 0.188729 -0.178864 0.094363 )
mulPerElem Transform3:
( 0.083191 0.059749 -0.032503 -0.045255 )
( -0.007625 0.007748 -0.263503 0.259311 )
( 0.094363 0.188729 -0.156546 -0.078272 )
absPerElem Transform3:
( 0.553800 0.107890 0.301261 0.150218 )
( 0.014688 0.527503 0.499529 0.519112 )
( 0.464365 0.406423 0.385180 0.203209 )
inverse Transform3:
( 0.003445 1.703147 -2.211457 -1.332994 )
( 4.765344 1.545948 -5.732023 -1.251475 )
( 5.032312 3.684490 -6.118052 -2.399958 )
inverse(Transform3) * Transform3:
( 1.000000 0.000000 -0.000000 -0.000000 )
( 0.000000 1.000000 -0.000000 0.000000 )
( 0.000000 0.000000 1.000000 -0.000000 )
orthoInverse Transform3:
( -0.806392 -0.302338 0.508256 0.139094 )
( -0.574608 0.197327 -0.794285 -0.350157 )
( 0.139850 -0.932552 -0.332848 0.437469 )
orthoInverse(Transform3) * Transform3:
( 1.000000 0.000000 0.000000 -0.000000 )
( 0.000000 1.000000 -0.000000 0.000000 )
( 0.000000 -0.000000 1.000000 0.000000 )
__end__

View File

@@ -0,0 +1,474 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
void
Matrix3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector3 tmpV3_0;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 );
vmathSoaM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" );
vmathSoaM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" );
vmathSoaM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 );
vmathSoaM3Prints( &tmpM3_2, "mulPerElem Matrix3" );
vmathSoaM3AbsPerElem( &tmpM3_3, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_3, "absPerElem Matrix3" );
vmathSoaM3Transpose( &tmpM3_4, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_4, "transpose Matrix3" );
vmathSoaM3Inverse( &tmpM3_5, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_5, "inverse Matrix3" );
vmathSoaM3Inverse( &tmpM3_6, &a_Matrix3 );
vmathSoaM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" );
printf("%f\n", getfloat(vmathSoaM3Determinant( &a_Matrix3 )) );
vmathSoaV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &tmpM3_8, "outer Vector3" );
vmathSoaV3RowMul( &tmpV3_0, &a_Vector3, &a_Matrix3 );
vmathSoaV3Prints( &tmpV3_0, "rowMul Vector3" );
vmathSoaV3CrossMatrix( &tmpM3_9, &a_Vector3 );
vmathSoaM3Prints( &tmpM3_9, "crossMatrix" );
vmathSoaV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 );
vmathSoaM3Prints( &tmpM3_10, "crossMatrixMul" );
}
void
Matrix4_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3;
VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7;
VmathSoaMatrix3 tmpM3_0;
VmathSoaMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat;
VmathSoaVector4 tmpV4_0;
VmathSoaQuat tmpQ_0;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 );
vmathSoaM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" );
vmathSoaM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" );
vmathSoaM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 );
vmathSoaM4Prints( &tmpM4_2, "mulPerElem Matrix4" );
vmathSoaM4AbsPerElem( &tmpM4_3, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_3, "absPerElem Matrix4" );
vmathSoaM4Transpose( &tmpM4_4, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_4, "transpose Matrix4" );
vmathSoaM4Inverse( &tmpM4_5, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_5, "inverse Matrix4" );
vmathSoaM4Inverse( &tmpM4_6, &a_Matrix4 );
vmathSoaM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" );
vmathSoaV4MakeFromElems( &tmpV4_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) );
vmathSoaM4SetRow( &a_Matrix4, 3, &tmpV4_0 );
vmathSoaQNormalize( &tmpQ_0, &a_Quat );
vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 );
vmathSoaM4SetUpper3x3( &a_Matrix4, &tmpM3_0 );
vmathSoaM4AffineInverse( &tmpM4_8, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_8, "affineInverse Matrix4" );
vmathSoaM4AffineInverse( &tmpM4_9, &a_Matrix4 );
vmathSoaM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" );
vmathSoaM4OrthoInverse( &tmpM4_11, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_11, "orthoInverse Matrix4" );
vmathSoaM4OrthoInverse( &tmpM4_12, &a_Matrix4 );
vmathSoaM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 );
vmathSoaM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" );
printf("%f\n", getfloat(vmathSoaM4Determinant( &a_Matrix4 )) );
vmathSoaV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 );
vmathSoaM4Prints( &tmpM4_14, "outer Vector4" );
}
void
Transform3_methods_test()
{
VmathSoaMatrix3 a_Matrix3, b_Matrix3;
VmathSoaMatrix4 a_Matrix4, b_Matrix4;
VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6;
VmathSoaMatrix3 tmpM3_0;
VmathSoaTransform3 tmpT3_7, tmpT3_8, tmpT3_9;
VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3;
VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 );
vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" );
vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" );
vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 );
vmathSoaP3Prints( &a_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &b_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &c_Point3, "set Point3 with floats" );
vmathSoaP3Prints( &d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 );
vmathSoaQPrints( &a_Quat, "set Quat with floats" );
vmathSoaQPrints( &b_Quat, "set Quat with floats" );
vmathSoaQPrints( &c_Quat, "set Quat with floats" );
vmathSoaQPrints( &d_Quat, "set Quat with floats" );
vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 );
vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" );
vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" );
vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 );
vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 );
vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" );
vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" );
vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 );
vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 );
vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" );
vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" );
vmathSoaT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 );
vmathSoaT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" );
vmathSoaT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" );
vmathSoaT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 );
vmathSoaT3Prints( &tmpT3_2, "mulPerElem Transform3" );
vmathSoaT3AbsPerElem( &tmpT3_3, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_3, "absPerElem Transform3" );
vmathSoaT3Inverse( &tmpT3_4, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_4, "inverse Transform3" );
vmathSoaT3Inverse( &tmpT3_5, &a_Transform3 );
vmathSoaT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" );
vmathSoaQNormalize( &tmpQ_0, &a_Quat );
vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 );
vmathSoaT3SetUpper3x3( &a_Transform3, &tmpM3_0 );
vmathSoaT3OrthoInverse( &tmpT3_7, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_7, "orthoInverse Transform3" );
vmathSoaT3OrthoInverse( &tmpT3_8, &a_Transform3 );
vmathSoaT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 );
vmathSoaT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,426 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#define _VECTORMATH_SOA_TEST
#include "vectormath_soa.h"
#include "test.h"
int iteration = 0;
using namespace Vectormath;
using namespace Vectormath::Soa;
void
Matrix3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" );
print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" );
print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" );
print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" );
print( transpose( a_Matrix3 ), "transpose Matrix3" );
print( inverse( a_Matrix3 ), "inverse Matrix3" );
print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" );
printf("%f\n", getfloat(determinant( a_Matrix3 )) );
print( outer( a_Vector3, b_Vector3 ), "outer Vector3" );
print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" );
print( crossMatrix( a_Vector3 ), "crossMatrix" );
print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" );
}
void
Matrix4_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" );
print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" );
print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" );
print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" );
print( transpose( a_Matrix4 ), "transpose Matrix4" );
print( inverse( a_Matrix4 ), "inverse Matrix4" );
print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" );
a_Matrix4.setRow( 3, Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) );
a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) );
print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" );
print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" );
print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" );
print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" );
printf("%f\n", getfloat(determinant( a_Matrix4 )) );
print( outer( a_Vector4, b_Vector4 ), "outer Vector4" );
}
void
Transform3_methods_test()
{
Matrix3 a_Matrix3, b_Matrix3;
Matrix4 a_Matrix4, b_Matrix4;
Transform3 a_Transform3, b_Transform3;
Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3;
Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4;
Point3 a_Point3, b_Point3, c_Point3, d_Point3;
Quat a_Quat, b_Quat, c_Quat, d_Quat;
vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6;
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 );
print( a_Vector3, "set Vector3 with floats" );
print( b_Vector3, "set Vector3 with floats" );
print( c_Vector3, "set Vector3 with floats" );
print( d_Vector3, "set Vector3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Vector4, "set Vector4 with floats" );
print( b_Vector4, "set Vector4 with floats" );
print( c_Vector4, "set Vector4 with floats" );
print( d_Vector4, "set Vector4 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
a_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Point3 = Point3( rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
c_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
d_Point3 = Point3( rndflt1, rndflt2, rndflt3 );
print( a_Point3, "set Point3 with floats" );
print( b_Point3, "set Point3 with floats" );
print( c_Point3, "set Point3 with floats" );
print( d_Point3, "set Point3 with floats" );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt3 = randfloat();
rndflt4 = randfloat();
rndflt5 = randfloat();
rndflt6 = randfloat();
b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
rndflt1 = randfloat();
rndflt2 = randfloat();
rndflt3 = randfloat();
rndflt4 = randfloat();
d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 );
print( a_Quat, "set Quat with floats" );
print( b_Quat, "set Quat with floats" );
print( c_Quat, "set Quat with floats" );
print( d_Quat, "set Quat with floats" );
a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 );
b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 );
print( a_Matrix3, "set Matrix3 columns" );
print( b_Matrix3, "set Matrix3 columns" );
a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 );
b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 );
print( a_Matrix4, "set Matrix4 columns" );
print( b_Matrix4, "set Matrix4 columns" );
a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 );
b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 );
print( a_Transform3, "set Transform3 columns" );
print( b_Transform3, "set Transform3 columns" );
print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" );
print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" );
print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" );
print( absPerElem( a_Transform3 ), "absPerElem Transform3" );
print( inverse( a_Transform3 ), "inverse Transform3" );
print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" );
a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) );
print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" );
print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" );
}
int main()
{
int i;
printf("\n __begin__ \n");
for ( i = 0; i < 2; i++ ) {
Matrix3_methods_test();
Matrix4_methods_test();
Transform3_methods_test();
}
printf("\n __end__ \n");
return 0;
}

View File

@@ -0,0 +1,81 @@
%define lib_version 1.0.1
Summary: Vector math library
Name: vectormath
Version: %{lib_version}
Release: 1
License: BSD
Group: Development/Libraries
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
Vector math library.
%ifarch ppc ppc64
%define _lib_arch ppu
%endif
%ifarch i386 x86_64
%define _lib_arch SSE
%endif
%if %{undefined _lib_arch}
%define _lib_arch scalar
%endif
%package -n %{name}-devel
Summary: Vector math library.
Group: Development/Libraries
%ifarch ppc ppc64
Requires: simdmath-devel
%endif
%description -n %{name}-devel
Vector math library.
%ifarch ppc ppc64
%package -n spu-%{name}-devel
Summary: Vector math library.
Group: Development/Libraries
Requires: spu-simdmath-devel
%description -n spu-%{name}-devel
Vector math library.
%endif
%prep
%setup -q
%build
%install
rm -rf %{buildroot}
make ARCH=%{_lib_arch} DESTDIR=%{buildroot} install
%ifarch ppc ppc64
make ARCH=spu DESTDIR=%{buildroot} install
%endif
mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version}
cp README LICENSE doc/*.pdf %{buildroot}/%{_docdir}/%{name}-%{version}/
%clean
rm -rf %{buildroot}
%files -n %{name}-devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_docdir}/*
%ifarch ppc ppc64
%files -n spu-%{name}-devel
%defattr(-,root,root,-)
%{_prefix}/spu/include/*
%endif
%changelog
* Wed Aug 8 2007 Kazunori Asayama <asayama@sm.sony.co.jp> - 1.0.1-1
- Initial build.