added tests for Vector Math, modified Makefile, added helper include files
This commit is contained in:
@@ -1,128 +1,119 @@
|
||||
# Makefile for testsuite for the PPU SIMD math library
|
||||
# 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.
|
||||
|
||||
TESTS = main_vmtest
|
||||
|
||||
STATIC_TESTS = $(TESTS)
|
||||
SHARED_TESTS = $(TESTS:=.shared)
|
||||
ALL_TESTS = $(STATIC_TESTS) $(SHARED_TESTS)
|
||||
|
||||
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 =
|
||||
|
||||
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++
|
||||
|
||||
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)'
|
||||
|
||||
LIB_BASE = simdmath
|
||||
LIB_NAME = lib$(LIB_BASE)
|
||||
STATIC_LIB = $(LIB_NAME).a
|
||||
SHARED_LIB = $(LIB_NAME).so
|
||||
|
||||
TEST_CMD = $(TEST_CMD_PPU)
|
||||
|
||||
#COMMON_OBJS = testutils.o
|
||||
|
||||
|
||||
all: $(ALL_TESTS)
|
||||
|
||||
|
||||
$(STATIC_TESTS): %: %.o ../simdmathlibrary/ppu/$(STATIC_LIB) $(COMMON_OBJS)
|
||||
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(STATIC_LDFLAGS_PPU) -o $@
|
||||
|
||||
$(SHARED_TESTS): %.shared: %.o ../simdmathlibrary/ppu/$(SHARED_LIB) $(COMMON_OBJS)
|
||||
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(SHARED_LDFLAGS_PPU) -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f $(STATIC_TESTS) $(SHARED_TESTS)
|
||||
rm -f core*
|
||||
|
||||
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 $<
|
||||
|
||||
# Makefile for vector math library.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# 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
|
||||
#
|
||||
|
||||
topdir = .
|
||||
ARCH = scalar
|
||||
|
||||
prefix_spu = /usr/spu
|
||||
|
||||
ARCH_DIRS = $(ARCH)
|
||||
ARCH_INSTALL= $(ARCH_INSTALL_$(ARCH))
|
||||
ARCH_CHECK= $(ARCH_CHECK_$(ARCH))
|
||||
|
||||
prefix = $(if $(prefix_$(ARCH)),$(prefix_$(ARCH)),/usr)
|
||||
DESTDIR =
|
||||
|
||||
COMMON_DIRS = scalar
|
||||
|
||||
INSTALL = install
|
||||
|
||||
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
|
||||
|
||||
TAR_NAME = $(LIB_BASE)-$(LIB_FULL_VERSION)
|
||||
TAR_BALL = $(TAR_NAME).tar.gz
|
||||
|
||||
all:
|
||||
@true
|
||||
|
||||
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
|
||||
|
||||
check:
|
||||
$(MAKE) -C tests ARCH=$(ARCH) check
|
||||
|
||||
clean:
|
||||
$(MAKE) -C tests clean
|
||||
-rm -f $(TAR_BALL)
|
||||
|
||||
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
|
||||
|
||||
@@ -1,86 +1,13 @@
|
||||
Vector math library
|
||||
|
||||
|
||||
* Overview
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -113,8 +113,8 @@ static inline __m128 vec_ctf(__m128 x, int a)
|
||||
SSE64 sse64;
|
||||
sse64.m128 = x;
|
||||
__m128 result =_mm_movelh_ps(
|
||||
_mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m01),
|
||||
_mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m23));
|
||||
_mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m01),
|
||||
_mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m23));
|
||||
_mm_empty();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,379 +1,379 @@
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
if (__builtin_constant_p(_x) & __builtin_constant_p(_y) &
|
||||
__builtin_constant_p(_z) & __builtin_constant_p(_w)) {
|
||||
result->vec128 = (vec_float4){_x, _y, _z, _w};
|
||||
} else {
|
||||
float *pf = (float *)&result->vec128;
|
||||
pf[0] = _x;
|
||||
pf[1] = _y;
|
||||
pf[2] = _z;
|
||||
pf[3] = _w;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
result->vec128 = xyz->vec128;
|
||||
_vmathVfSetElement(result->vec128, _w, 3);
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->vec128 = vec->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->vec128 = _vmathVfSplatScalar(scalar);
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
|
||||
{
|
||||
result->vec128 = vf4;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
result->vec128 = _VECTORMATH_UNIT_0001;
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
|
||||
cosAngle = vec_splat( cosAngle, 0 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
|
||||
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = _vmathVfSplatScalar(t);
|
||||
oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
|
||||
angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
|
||||
angles = vec_mergeh( angles, oneMinusT );
|
||||
angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, vec_splat( sines, 0 ) );
|
||||
scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask );
|
||||
scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask );
|
||||
result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
|
||||
{
|
||||
return quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F );
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _x, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 0);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _y, 1);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 1);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _z, 2);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 2);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _w, 3);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 3);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, value, idx);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, idx);
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = vec_add( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = vec_sub( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = negatef4( quat->vec128 );
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 );
|
||||
return _vmathVfGetElement(result, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
return _vmathVfGetElement(result, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 crossVec, tmpV3_0;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
|
||||
cosAngle = vec_splat( cosAngle, 0 );
|
||||
cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
crossVec = tmpV3_0;
|
||||
res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = quat0->vec128;
|
||||
rdata = quat1->vec128;
|
||||
tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW );
|
||||
tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW );
|
||||
qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
l_wxyz = vec_sld( ldata, ldata, 12 );
|
||||
r_wxyz = vec_sld( rdata, rdata, 12 );
|
||||
qw = vec_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = vec_madd( l_wxyz, r_wxyz, product );
|
||||
qw = vec_sub( qw, vec_sld( xy, xy, 8 ) );
|
||||
result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat->vec128;
|
||||
vdata = vec->vec128;
|
||||
tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW );
|
||||
tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW );
|
||||
wwww = vec_splat( qdata, 3 );
|
||||
qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product );
|
||||
qw = vec_add( vec_sld( product, product, 8 ), qw );
|
||||
tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW );
|
||||
res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
res = vec_madd( wwww, qv, res );
|
||||
res = vec_madd( tmp0, tmp1, res );
|
||||
res = vec_nmsub( tmp2, tmp3, res );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
unsigned int tmp;
|
||||
tmp = (unsigned int)-(select1 > 0);
|
||||
result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
if (__builtin_constant_p(_x) & __builtin_constant_p(_y) &
|
||||
__builtin_constant_p(_z) & __builtin_constant_p(_w)) {
|
||||
result->vec128 = (vec_float4){_x, _y, _z, _w};
|
||||
} else {
|
||||
float *pf = (float *)&result->vec128;
|
||||
pf[0] = _x;
|
||||
pf[1] = _y;
|
||||
pf[2] = _z;
|
||||
pf[3] = _w;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
result->vec128 = xyz->vec128;
|
||||
_vmathVfSetElement(result->vec128, _w, 3);
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->vec128 = vec->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->vec128 = _vmathVfSplatScalar(scalar);
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
|
||||
{
|
||||
result->vec128 = vf4;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
result->vec128 = _VECTORMATH_UNIT_0001;
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
|
||||
cosAngle = vec_splat( cosAngle, 0 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
|
||||
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = _vmathVfSplatScalar(t);
|
||||
oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
|
||||
angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
|
||||
angles = vec_mergeh( angles, oneMinusT );
|
||||
angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, vec_splat( sines, 0 ) );
|
||||
scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask );
|
||||
scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask );
|
||||
result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
|
||||
{
|
||||
return quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F );
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _x, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 0);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _y, 1);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 1);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _z, 2);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 2);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, _w, 3);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, 3);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
_vmathVfSetElement(result->vec128, value, idx);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return _vmathVfGetElement(quat->vec128, idx);
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = vec_add( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = vec_sub( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = negatef4( quat->vec128 );
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 );
|
||||
return _vmathVfGetElement(result, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
return _vmathVfGetElement(result, 0);
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 crossVec, tmpV3_0;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
|
||||
cosAngle = vec_splat( cosAngle, 0 );
|
||||
cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
crossVec = tmpV3_0;
|
||||
res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 );
|
||||
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = quat0->vec128;
|
||||
rdata = quat1->vec128;
|
||||
tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW );
|
||||
tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW );
|
||||
qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
l_wxyz = vec_sld( ldata, ldata, 12 );
|
||||
r_wxyz = vec_sld( rdata, rdata, 12 );
|
||||
qw = vec_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = vec_madd( l_wxyz, r_wxyz, product );
|
||||
qw = vec_sub( qw, vec_sld( xy, xy, 8 ) );
|
||||
result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat->vec128;
|
||||
vdata = vec->vec128;
|
||||
tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW );
|
||||
tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW );
|
||||
wwww = vec_splat( qdata, 3 );
|
||||
qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product );
|
||||
qw = vec_add( vec_sld( product, product, 8 ), qw );
|
||||
tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW );
|
||||
tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW );
|
||||
res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
res = vec_madd( wwww, qv, res );
|
||||
res = vec_madd( tmp0, tmp1, res );
|
||||
res = vec_nmsub( tmp2, tmp3, res );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
unsigned int tmp;
|
||||
tmp = (unsigned int)-(select1 > 0);
|
||||
result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,312 +1,312 @@
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFrom128(&result, vf4);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGet128(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFrom128(&result, vf4);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGet128(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,415 +1,415 @@
|
||||
/*
|
||||
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_QUAT_SOA_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetXYZ( result, xyz );
|
||||
vmathSoaQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 vec128 = quat->vec128;
|
||||
result->x = vec_splat( vec128, 0 );
|
||||
result->y = vec_splat( vec128, 1 );
|
||||
result->z = vec_splat( vec128, 2 );
|
||||
result->w = vec_splat( vec128, 3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat0->vec128, quat2->vec128 );
|
||||
tmp1 = vec_mergeh( quat1->vec128, quat3->vec128 );
|
||||
tmp2 = vec_mergel( quat0->vec128, quat2->vec128 );
|
||||
tmp3 = vec_mergel( quat1->vec128, quat3->vec128 );
|
||||
result->x = vec_mergeh( tmp0, tmp1 );
|
||||
result->y = vec_mergel( tmp0, tmp1 );
|
||||
result->z = vec_mergeh( tmp2, tmp3 );
|
||||
result->w = vec_mergel( tmp2, tmp3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, ((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}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
VmathSoaQuat tmpQ_0, tmpQ_1;
|
||||
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathSoaQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat start, tmpQ_0, tmpQ_1;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
vmathSoaQSetX( &start, vec_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
|
||||
vmathSoaQSetY( &start, vec_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
|
||||
vmathSoaQSetZ( &start, vec_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
|
||||
vmathSoaQSetW( &start, vec_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
|
||||
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat tmp0, tmp1;
|
||||
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathSoaQSlerp( result, vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat->x, quat->z );
|
||||
tmp1 = vec_mergeh( quat->y, quat->w );
|
||||
tmp2 = vec_mergel( quat->x, quat->z );
|
||||
tmp3 = vec_mergel( quat->y, quat->w );
|
||||
vmathQMakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) );
|
||||
vmathQMakeFrom128( result1, vec_mergel( tmp0, tmp1 ) );
|
||||
vmathQMakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) );
|
||||
vmathQMakeFrom128( result3, vec_mergel( tmp2, tmp3 ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = vec_add( quat0->x, quat1->x );
|
||||
result->y = vec_add( quat0->y, quat1->y );
|
||||
result->z = vec_add( quat0->z, quat1->z );
|
||||
result->w = vec_add( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = vec_sub( quat0->x, quat1->x );
|
||||
result->y = vec_sub( quat0->y, quat1->y );
|
||||
result->z = vec_sub( quat0->z, quat1->z );
|
||||
result->w = vec_sub( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = vec_madd( quat->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->y = vec_madd( quat->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->z = vec_madd( quat->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->w = vec_madd( quat->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = divf4( quat->x, scalar );
|
||||
result->y = divf4( quat->y, scalar );
|
||||
result->z = divf4( quat->z, scalar );
|
||||
result->w = divf4( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = negatef4( quat->x );
|
||||
result->y = negatef4( quat->y );
|
||||
result->z = negatef4( quat->z );
|
||||
result->w = negatef4( quat->w );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat->x, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat->y, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat->z, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat->w, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
|
||||
{
|
||||
return sqrtf4( vmathSoaQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = vmathSoaQNorm( quat );
|
||||
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
|
||||
result->x = vec_madd( quat->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->y = vec_madd( quat->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->z = vec_madd( quat->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->w = vec_madd( quat->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0, tmpV3_1;
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
|
||||
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0;
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->y, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->z, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_sub( vec_sub( vec_sub( vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_madd( quat->w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_madd( quat->w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_madd( quat->w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_add( vec_add( vec_madd( quat->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->x = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->y = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->z = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
|
||||
{
|
||||
result->x = vec_sel( quat0->x, quat1->x, select1 );
|
||||
result->y = vec_sel( quat0->y, quat1->y, select1 );
|
||||
result->z = vec_sel( quat0->z, quat1->z, select1 );
|
||||
result->w = vec_sel( quat0->w, quat1->w, select1 );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetXYZ( result, xyz );
|
||||
vmathSoaQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 vec128 = quat->vec128;
|
||||
result->x = vec_splat( vec128, 0 );
|
||||
result->y = vec_splat( vec128, 1 );
|
||||
result->z = vec_splat( vec128, 2 );
|
||||
result->w = vec_splat( vec128, 3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat0->vec128, quat2->vec128 );
|
||||
tmp1 = vec_mergeh( quat1->vec128, quat3->vec128 );
|
||||
tmp2 = vec_mergel( quat0->vec128, quat2->vec128 );
|
||||
tmp3 = vec_mergel( quat1->vec128, quat3->vec128 );
|
||||
result->x = vec_mergeh( tmp0, tmp1 );
|
||||
result->y = vec_mergel( tmp0, tmp1 );
|
||||
result->z = vec_mergeh( tmp2, tmp3 );
|
||||
result->w = vec_mergel( tmp2, tmp3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, ((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}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
VmathSoaQuat tmpQ_0, tmpQ_1;
|
||||
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathSoaQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat start, tmpQ_0, tmpQ_1;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
vmathSoaQSetX( &start, vec_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
|
||||
vmathSoaQSetY( &start, vec_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
|
||||
vmathSoaQSetZ( &start, vec_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
|
||||
vmathSoaQSetW( &start, vec_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
|
||||
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat tmp0, tmp1;
|
||||
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathSoaQSlerp( result, vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat->x, quat->z );
|
||||
tmp1 = vec_mergeh( quat->y, quat->w );
|
||||
tmp2 = vec_mergel( quat->x, quat->z );
|
||||
tmp3 = vec_mergel( quat->y, quat->w );
|
||||
vmathQMakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) );
|
||||
vmathQMakeFrom128( result1, vec_mergel( tmp0, tmp1 ) );
|
||||
vmathQMakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) );
|
||||
vmathQMakeFrom128( result3, vec_mergel( tmp2, tmp3 ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = vec_add( quat0->x, quat1->x );
|
||||
result->y = vec_add( quat0->y, quat1->y );
|
||||
result->z = vec_add( quat0->z, quat1->z );
|
||||
result->w = vec_add( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = vec_sub( quat0->x, quat1->x );
|
||||
result->y = vec_sub( quat0->y, quat1->y );
|
||||
result->z = vec_sub( quat0->z, quat1->z );
|
||||
result->w = vec_sub( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = vec_madd( quat->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->y = vec_madd( quat->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->z = vec_madd( quat->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->w = vec_madd( quat->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = divf4( quat->x, scalar );
|
||||
result->y = divf4( quat->y, scalar );
|
||||
result->z = divf4( quat->z, scalar );
|
||||
result->w = divf4( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = negatef4( quat->x );
|
||||
result->y = negatef4( quat->y );
|
||||
result->z = negatef4( quat->z );
|
||||
result->w = negatef4( quat->w );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat->x, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat->y, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat->z, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat->w, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
|
||||
{
|
||||
return sqrtf4( vmathSoaQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = vmathSoaQNorm( quat );
|
||||
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
|
||||
result->x = vec_madd( quat->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->y = vec_madd( quat->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->z = vec_madd( quat->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result->w = vec_madd( quat->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0, tmpV3_1;
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
|
||||
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0;
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->y, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->z, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_sub( vec_sub( vec_sub( vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_madd( quat->w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_madd( quat->w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_madd( quat->w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_add( vec_add( vec_madd( quat->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->x = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->y = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result->z = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
|
||||
{
|
||||
result->x = vec_sel( quat0->x, quat1->x, select1 );
|
||||
result->y = vec_sel( quat0->y, quat1->y, select1 );
|
||||
result->z = vec_sel( quat0->z, quat1->z, select1 );
|
||||
result->w = vec_sel( quat0->w, quat1->w, select1 );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,319 +1,319 @@
|
||||
/*
|
||||
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_QUAT_SOA_V_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromAos(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
|
||||
{
|
||||
vmathSoaQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
vmathSoaQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
vmathSoaQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
vmathSoaQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
vmathSoaQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
|
||||
{
|
||||
return vmathSoaQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
return vmathSoaQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
|
||||
{
|
||||
vmathSoaQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
|
||||
{
|
||||
vmathSoaQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_V_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromAos(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
|
||||
{
|
||||
vmathSoaQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
vmathSoaQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
vmathSoaQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
vmathSoaQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
vmathSoaQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
|
||||
{
|
||||
return vmathSoaQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
return vmathSoaQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
|
||||
{
|
||||
vmathSoaQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
|
||||
{
|
||||
vmathSoaQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,261 +1,261 @@
|
||||
/*
|
||||
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 _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <altivec.h>
|
||||
#include "vec_types.h"
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
vec_uint4 mData;
|
||||
|
||||
inline boolInVec(vec_uint4 vec);
|
||||
public:
|
||||
inline boolInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
#else
|
||||
// implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// bool value is splatted across all word slots of vector as 0 (false) or -1 (true)
|
||||
//
|
||||
inline vec_uint4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(vec_uint4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(scalar))
|
||||
{
|
||||
const unsigned int mask = -(int)scalar;
|
||||
mData = (vec_uint4){mask, mask, mask, mask};
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
unsigned int mask = -(int)scalar;
|
||||
vec_uint4 vec = vec_ld(0, &mask);
|
||||
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
#else
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
#endif
|
||||
{
|
||||
return vec_all_gt(mData, ((vec_uint4){0,0,0,0}));
|
||||
}
|
||||
|
||||
inline
|
||||
vec_uint4
|
||||
boolInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(vec_nor(mData, mData));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_and(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_or(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_xor(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
/*
|
||||
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 _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <altivec.h>
|
||||
#include "../c/vec_types.h"
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
vec_uint4 mData;
|
||||
|
||||
inline boolInVec(vec_uint4 vec);
|
||||
public:
|
||||
inline boolInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
#else
|
||||
// implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// bool value is splatted across all word slots of vector as 0 (false) or -1 (true)
|
||||
//
|
||||
inline vec_uint4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(vec_uint4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(scalar))
|
||||
{
|
||||
const unsigned int mask = -(int)scalar;
|
||||
mData = (vec_uint4){mask, mask, mask, mask};
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
unsigned int mask = -(int)scalar;
|
||||
vec_uint4 vec = vec_ld(0, &mask);
|
||||
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
#else
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
#endif
|
||||
{
|
||||
return vec_all_gt(mData, ((vec_uint4){0,0,0,0}));
|
||||
}
|
||||
|
||||
inline
|
||||
vec_uint4
|
||||
boolInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(vec_nor(mData, mData));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_and(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_or(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec_xor(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
|
||||
@@ -1,361 +1,361 @@
|
||||
/*
|
||||
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 _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <altivec.h>
|
||||
#include <stddef.h>
|
||||
#include "vec_types.h"
|
||||
#include "simdmath.h"
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
vec_float4 mData;
|
||||
|
||||
inline floatInVec(vec_float4 vec);
|
||||
public:
|
||||
inline floatInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// construct from a slot of vec_float4
|
||||
//
|
||||
inline floatInVec(vec_float4 vec, int slot);
|
||||
|
||||
// explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
// implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// float value is splatted across all word slots of vector
|
||||
//
|
||||
inline vec_float4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
inline const floatInVec operator -- (int);
|
||||
inline floatInVec& operator ++ ();
|
||||
inline floatInVec& operator -- ();
|
||||
inline const floatInVec operator - () const;
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = vec_ctf(vec_sub((vec_uint4){0,0,0,0}, vec.get128()), 0);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec, int slot)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(slot))
|
||||
{
|
||||
mData = vec_splat(vec, slot);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const vec_uchar16 shiftpattern = vec_lvsl(0, (float *)(size_t)(slot << 2));
|
||||
mData = vec_splat(vec_perm(vec, vec, shiftpattern), 0);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(scalar))
|
||||
{
|
||||
mData = (vec_float4){scalar, scalar, scalar, scalar};
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
vec_float4 vec = vec_ld(0, &scalar);
|
||||
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &scalar)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
#else
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
#endif
|
||||
{
|
||||
return *((float *)&mData);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_float4
|
||||
floatInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec((vec_float4)vec_xor((vec_uint4)mData, (vec_uint4){0x80000000,0x80000000,0x80000000,0x80000000}));
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_madd(vec0.get128(), vec1.get128(), (vec_float4){0,0,0,0}));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(divf4(num.get128(), den.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_add(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_sub(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpgt(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpgt(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
/*
|
||||
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 _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <altivec.h>
|
||||
#include <stddef.h>
|
||||
#include <simdmath.h>
|
||||
#include "../c/vec_types.h"
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
vec_float4 mData;
|
||||
|
||||
inline floatInVec(vec_float4 vec);
|
||||
public:
|
||||
inline floatInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// construct from a slot of vec_float4
|
||||
//
|
||||
inline floatInVec(vec_float4 vec, int slot);
|
||||
|
||||
// explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
// implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// float value is splatted across all word slots of vector
|
||||
//
|
||||
inline vec_float4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
inline const floatInVec operator -- (int);
|
||||
inline floatInVec& operator ++ ();
|
||||
inline floatInVec& operator -- ();
|
||||
inline const floatInVec operator - () const;
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = vec_ctf(vec_sub((vec_uint4){0,0,0,0}, vec.get128()), 0);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec, int slot)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(slot))
|
||||
{
|
||||
mData = vec_splat(vec, slot);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const vec_uchar16 shiftpattern = vec_lvsl(0, (float *)(size_t)(slot << 2));
|
||||
mData = vec_splat(vec_perm(vec, vec, shiftpattern), 0);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
if (__builtin_constant_p(scalar))
|
||||
{
|
||||
mData = (vec_float4){scalar, scalar, scalar, scalar};
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
vec_float4 vec = vec_ld(0, &scalar);
|
||||
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &scalar)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
#else
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
#endif
|
||||
{
|
||||
return *((float *)&mData);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_float4
|
||||
floatInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec((vec_float4)vec_xor((vec_uint4)mData, (vec_uint4){0x80000000,0x80000000,0x80000000,0x80000000}));
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_madd(vec0.get128(), vec1.get128(), (vec_float4){0,0,0,0}));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(divf4(num.get128(), den.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_add(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec_sub(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpgt(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpgt(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,479 +1,479 @@
|
||||
/*
|
||||
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_QUAT_SOA_CPP_H
|
||||
#define _VECTORMATH_QUAT_SOA_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Soa {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat )
|
||||
{
|
||||
vec_float4 vec128 = quat.get128();
|
||||
mX = vec_splat( vec128, 0 );
|
||||
mY = vec_splat( vec128, 1 );
|
||||
mZ = vec_splat( vec128, 2 );
|
||||
mW = vec_splat( vec128, 3 );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat0.get128(), quat2.get128() );
|
||||
tmp1 = vec_mergeh( quat1.get128(), quat3.get128() );
|
||||
tmp2 = vec_mergel( quat0.get128(), quat2.get128() );
|
||||
tmp3 = vec_mergel( quat1.get128(), quat3.get128() );
|
||||
mX = vec_mergeh( tmp0, tmp1 );
|
||||
mY = vec_mergel( tmp0, tmp1 );
|
||||
mZ = vec_mergeh( tmp2, tmp3 );
|
||||
mW = vec_mergel( tmp2, tmp3 );
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( ((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}) );
|
||||
}
|
||||
|
||||
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.setX( vec_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
|
||||
start.setY( vec_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
|
||||
start.setZ( vec_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
|
||||
start.setW( vec_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
|
||||
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( mX, mZ );
|
||||
tmp1 = vec_mergeh( mY, mW );
|
||||
tmp2 = vec_mergel( mX, mZ );
|
||||
tmp3 = vec_mergel( mY, mW );
|
||||
result0 = Aos::Quat( vec_mergeh( tmp0, tmp1 ) );
|
||||
result1 = Aos::Quat( vec_mergel( tmp0, tmp1 ) );
|
||||
result2 = Aos::Quat( vec_mergeh( tmp2, tmp3 ) );
|
||||
result3 = Aos::Quat( vec_mergel( tmp2, tmp3 ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( vec_float4 _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( vec_float4 _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( vec_float4 _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( vec_float4 _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, vec_float4 value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline Quat::vec_float4_t & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_add( mX, quat.mX ),
|
||||
vec_add( mY, quat.mY ),
|
||||
vec_add( mZ, quat.mZ ),
|
||||
vec_add( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_sub( mX, quat.mX ),
|
||||
vec_sub( mY, quat.mY ),
|
||||
vec_sub( mZ, quat.mZ ),
|
||||
vec_sub( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
divf4( mX, scalar ),
|
||||
divf4( mY, scalar ),
|
||||
divf4( mZ, scalar ),
|
||||
divf4( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
negatef4( mX ),
|
||||
negatef4( mY ),
|
||||
negatef4( mZ ),
|
||||
negatef4( mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat0.getX(), quat1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat0.getY(), quat1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0.getZ(), quat1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0.getW(), quat1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 norm( const Quat & quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat.getX(), quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat.getY(), quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat.getZ(), quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat.getW(), quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 length( const Quat & quat )
|
||||
{
|
||||
return sqrtf4( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
|
||||
return Quat(
|
||||
vec_madd( quat.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mY, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mZ, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_sub( vec_sub( vec_madd( mW, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_madd( quat.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_madd( quat.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_madd( quat.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_add( vec_add( vec_madd( quat.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return Vector3(
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
|
||||
{
|
||||
return Quat(
|
||||
vec_sel( quat0.getX(), quat1.getX(), select1 ),
|
||||
vec_sel( quat0.getY(), quat1.getY(), select1 ),
|
||||
vec_sel( quat0.getZ(), quat1.getZ(), select1 ),
|
||||
vec_sel( quat0.getW(), quat1.getW(), select1 )
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Soa
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_CPP_H
|
||||
#define _VECTORMATH_QUAT_SOA_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Soa {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat )
|
||||
{
|
||||
vec_float4 vec128 = quat.get128();
|
||||
mX = vec_splat( vec128, 0 );
|
||||
mY = vec_splat( vec128, 1 );
|
||||
mZ = vec_splat( vec128, 2 );
|
||||
mW = vec_splat( vec128, 3 );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( quat0.get128(), quat2.get128() );
|
||||
tmp1 = vec_mergeh( quat1.get128(), quat3.get128() );
|
||||
tmp2 = vec_mergel( quat0.get128(), quat2.get128() );
|
||||
tmp3 = vec_mergel( quat1.get128(), quat3.get128() );
|
||||
mX = vec_mergeh( tmp0, tmp1 );
|
||||
mY = vec_mergel( tmp0, tmp1 );
|
||||
mZ = vec_mergeh( tmp2, tmp3 );
|
||||
mW = vec_mergel( tmp2, tmp3 );
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( ((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}) );
|
||||
}
|
||||
|
||||
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.setX( vec_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
|
||||
start.setY( vec_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
|
||||
start.setZ( vec_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
|
||||
start.setW( vec_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
|
||||
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
|
||||
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = vec_mergeh( mX, mZ );
|
||||
tmp1 = vec_mergeh( mY, mW );
|
||||
tmp2 = vec_mergel( mX, mZ );
|
||||
tmp3 = vec_mergel( mY, mW );
|
||||
result0 = Aos::Quat( vec_mergeh( tmp0, tmp1 ) );
|
||||
result1 = Aos::Quat( vec_mergel( tmp0, tmp1 ) );
|
||||
result2 = Aos::Quat( vec_mergeh( tmp2, tmp3 ) );
|
||||
result3 = Aos::Quat( vec_mergel( tmp2, tmp3 ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( vec_float4 _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( vec_float4 _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( vec_float4 _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( vec_float4 _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, vec_float4 value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline Quat::vec_float4_t & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_add( mX, quat.mX ),
|
||||
vec_add( mY, quat.mY ),
|
||||
vec_add( mZ, quat.mZ ),
|
||||
vec_add( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_sub( mX, quat.mX ),
|
||||
vec_sub( mY, quat.mY ),
|
||||
vec_sub( mZ, quat.mZ ),
|
||||
vec_sub( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
divf4( mX, scalar ),
|
||||
divf4( mY, scalar ),
|
||||
divf4( mZ, scalar ),
|
||||
divf4( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
negatef4( mX ),
|
||||
negatef4( mY ),
|
||||
negatef4( mZ ),
|
||||
negatef4( mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat0.getX(), quat1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat0.getY(), quat1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0.getZ(), quat1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat0.getW(), quat1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 norm( const Quat & quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = vec_madd( quat.getX(), quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
result = vec_add( result, vec_madd( quat.getY(), quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat.getZ(), quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
result = vec_add( result, vec_madd( quat.getW(), quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 length( const Quat & quat )
|
||||
{
|
||||
return sqrtf4( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
|
||||
return Quat(
|
||||
vec_madd( quat.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
|
||||
vec_madd( quat.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mY, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mZ, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_sub( vec_sub( vec_sub( vec_madd( mW, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = vec_sub( vec_add( vec_madd( quat.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpY = vec_sub( vec_add( vec_madd( quat.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpZ = vec_sub( vec_add( vec_madd( quat.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
tmpW = vec_add( vec_add( vec_madd( quat.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
|
||||
return Vector3(
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
|
||||
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
|
||||
{
|
||||
return Quat(
|
||||
vec_sel( quat0.getX(), quat1.getX(), select1 ),
|
||||
vec_sel( quat0.getY(), quat1.getY(), select1 ),
|
||||
vec_sel( quat0.getZ(), quat1.getZ(), select1 ),
|
||||
vec_sel( quat0.getW(), quat1.getW(), select1 )
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Soa
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,80 +1,80 @@
|
||||
/*
|
||||
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_VECIDX_AOS_H
|
||||
#define _VECTORMATH_VECIDX_AOS_H
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VecIdx
|
||||
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
|
||||
// subscripting operator.
|
||||
//
|
||||
|
||||
class VecIdx
|
||||
{
|
||||
private:
|
||||
typedef vec_float4 vec_float4_t;
|
||||
vec_float4_t &ref __attribute__ ((aligned(16)));
|
||||
int i __attribute__ ((aligned(16)));
|
||||
public:
|
||||
inline VecIdx( vec_float4_t& vec, int idx ): ref(vec) { i = idx; }
|
||||
|
||||
// implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined
|
||||
// in which case, implicitly casts to floatInVec, and one must call
|
||||
// getAsFloat to convert to float.
|
||||
//
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline operator floatInVec() const;
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
inline float operator =( float scalar );
|
||||
inline floatInVec operator =( floatInVec scalar );
|
||||
inline floatInVec operator =( const VecIdx& scalar );
|
||||
inline floatInVec operator *=( float scalar );
|
||||
inline floatInVec operator *=( floatInVec scalar );
|
||||
inline floatInVec operator /=( float scalar );
|
||||
inline floatInVec operator /=( floatInVec scalar );
|
||||
inline floatInVec operator +=( float scalar );
|
||||
inline floatInVec operator +=( floatInVec scalar );
|
||||
inline floatInVec operator -=( float scalar );
|
||||
inline floatInVec operator -=( floatInVec scalar );
|
||||
};
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_VECIDX_AOS_H
|
||||
#define _VECTORMATH_VECIDX_AOS_H
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VecIdx
|
||||
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
|
||||
// subscripting operator.
|
||||
//
|
||||
|
||||
class VecIdx
|
||||
{
|
||||
private:
|
||||
typedef vec_float4 vec_float4_t;
|
||||
vec_float4_t &ref __attribute__ ((aligned(16)));
|
||||
int i __attribute__ ((aligned(16)));
|
||||
public:
|
||||
inline VecIdx( vec_float4_t& vec, int idx ): ref(vec) { i = idx; }
|
||||
|
||||
// implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined
|
||||
// in which case, implicitly casts to floatInVec, and one must call
|
||||
// getAsFloat to convert to float.
|
||||
//
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline operator floatInVec() const;
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
inline float operator =( float scalar );
|
||||
inline floatInVec operator =( floatInVec scalar );
|
||||
inline floatInVec operator =( const VecIdx& scalar );
|
||||
inline floatInVec operator *=( float scalar );
|
||||
inline floatInVec operator *=( floatInVec scalar );
|
||||
inline floatInVec operator /=( float scalar );
|
||||
inline floatInVec operator /=( floatInVec scalar );
|
||||
inline floatInVec operator +=( float scalar );
|
||||
inline floatInVec operator +=( floatInVec scalar );
|
||||
inline floatInVec operator -=( float scalar );
|
||||
inline floatInVec operator -=( floatInVec scalar );
|
||||
};
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,368 +1,368 @@
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
vmathQSetXYZ( result, xyz );
|
||||
vmathQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
vmathQMakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start, tmpQ_0, tmpQ_1;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = vmathQDot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
vmathQNeg( &start, unitQuat0 );
|
||||
} else {
|
||||
vmathQCopy( &start, unitQuat0 );
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
vmathQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
vmathV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->x = ( quat0->x + quat1->x );
|
||||
result->y = ( quat0->y + quat1->y );
|
||||
result->z = ( quat0->z + quat1->z );
|
||||
result->w = ( quat0->w + quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->x = ( quat0->x - quat1->x );
|
||||
result->y = ( quat0->y - quat1->y );
|
||||
result->z = ( quat0->z - quat1->z );
|
||||
result->w = ( quat0->w - quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->x = ( quat->x * scalar );
|
||||
result->y = ( quat->y * scalar );
|
||||
result->z = ( quat->z * scalar );
|
||||
result->w = ( quat->w * scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->x = ( quat->x / scalar );
|
||||
result->y = ( quat->y / scalar );
|
||||
result->z = ( quat->z / scalar );
|
||||
result->w = ( quat->w / scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->x = -quat->x;
|
||||
result->y = -quat->y;
|
||||
result->z = -quat->z;
|
||||
result->w = -quat->w;
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0->x * quat1->x );
|
||||
result = ( result + ( quat0->y * quat1->y ) );
|
||||
result = ( result + ( quat0->z * quat1->z ) );
|
||||
result = ( result + ( quat0->w * quat1->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat->x * quat->x );
|
||||
result = ( result + ( quat->y * quat->y ) );
|
||||
result = ( result + ( quat->z * quat->z ) );
|
||||
result = ( result + ( quat->w * quat->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = vmathQNorm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
result->x = ( quat->x * lenInv );
|
||||
result->y = ( quat->y * lenInv );
|
||||
result->z = ( quat->z * lenInv );
|
||||
result->w = ( quat->w * lenInv );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 tmpV3_0, tmpV3_1;
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + vmathV3Dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathQMakeFromV3Scalar( result, &tmpV3_1, ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
VmathVector3 tmpV3_0;
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( ( quat0->w * quat1->x ) + ( quat0->x * quat1->w ) ) + ( quat0->y * quat1->z ) ) - ( quat0->z * quat1->y ) );
|
||||
tmpY = ( ( ( ( quat0->w * quat1->y ) + ( quat0->y * quat1->w ) ) + ( quat0->z * quat1->x ) ) - ( quat0->x * quat1->z ) );
|
||||
tmpZ = ( ( ( ( quat0->w * quat1->z ) + ( quat0->z * quat1->w ) ) + ( quat0->x * quat1->y ) ) - ( quat0->y * quat1->x ) );
|
||||
tmpW = ( ( ( ( quat0->w * quat1->w ) - ( quat0->x * quat1->x ) ) - ( quat0->y * quat1->y ) ) - ( quat0->z * quat1->z ) );
|
||||
vmathQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat->w * vec->x ) + ( quat->y * vec->z ) ) - ( quat->z * vec->y ) );
|
||||
tmpY = ( ( ( quat->w * vec->y ) + ( quat->z * vec->x ) ) - ( quat->x * vec->z ) );
|
||||
tmpZ = ( ( ( quat->w * vec->z ) + ( quat->x * vec->y ) ) - ( quat->y * vec->x ) );
|
||||
tmpW = ( ( ( quat->x * vec->x ) + ( quat->y * vec->y ) ) + ( quat->z * vec->z ) );
|
||||
result->x = ( ( ( ( tmpW * quat->x ) + ( tmpX * quat->w ) ) - ( tmpY * quat->z ) ) + ( tmpZ * quat->y ) );
|
||||
result->y = ( ( ( ( tmpW * quat->y ) + ( tmpY * quat->w ) ) - ( tmpZ * quat->x ) ) + ( tmpX * quat->z ) );
|
||||
result->z = ( ( ( ( tmpW * quat->z ) + ( tmpZ * quat->w ) ) - ( tmpX * quat->y ) ) + ( tmpY * quat->x ) );
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vmathQMakeFromElems( result, -quat->x, -quat->y, -quat->z, quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
result->x = ( select1 )? quat1->x : quat0->x;
|
||||
result->y = ( select1 )? quat1->y : quat0->y;
|
||||
result->z = ( select1 )? quat1->z : quat0->z;
|
||||
result->w = ( select1 )? quat1->w : quat0->w;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat->x, quat->y, quat->z, quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat->x, quat->y, quat->z, quat->w );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
vmathQSetXYZ( result, xyz );
|
||||
vmathQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
vmathQMakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start, tmpQ_0, tmpQ_1;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = vmathQDot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
vmathQNeg( &start, unitQuat0 );
|
||||
} else {
|
||||
vmathQCopy( &start, unitQuat0 );
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
vmathQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
vmathV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->x = ( quat0->x + quat1->x );
|
||||
result->y = ( quat0->y + quat1->y );
|
||||
result->z = ( quat0->z + quat1->z );
|
||||
result->w = ( quat0->w + quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->x = ( quat0->x - quat1->x );
|
||||
result->y = ( quat0->y - quat1->y );
|
||||
result->z = ( quat0->z - quat1->z );
|
||||
result->w = ( quat0->w - quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->x = ( quat->x * scalar );
|
||||
result->y = ( quat->y * scalar );
|
||||
result->z = ( quat->z * scalar );
|
||||
result->w = ( quat->w * scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->x = ( quat->x / scalar );
|
||||
result->y = ( quat->y / scalar );
|
||||
result->z = ( quat->z / scalar );
|
||||
result->w = ( quat->w / scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->x = -quat->x;
|
||||
result->y = -quat->y;
|
||||
result->z = -quat->z;
|
||||
result->w = -quat->w;
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0->x * quat1->x );
|
||||
result = ( result + ( quat0->y * quat1->y ) );
|
||||
result = ( result + ( quat0->z * quat1->z ) );
|
||||
result = ( result + ( quat0->w * quat1->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat->x * quat->x );
|
||||
result = ( result + ( quat->y * quat->y ) );
|
||||
result = ( result + ( quat->z * quat->z ) );
|
||||
result = ( result + ( quat->w * quat->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = vmathQNorm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
result->x = ( quat->x * lenInv );
|
||||
result->y = ( quat->y * lenInv );
|
||||
result->z = ( quat->z * lenInv );
|
||||
result->w = ( quat->w * lenInv );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 tmpV3_0, tmpV3_1;
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + vmathV3Dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathQMakeFromV3Scalar( result, &tmpV3_1, ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
VmathVector3 tmpV3_0;
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
vmathQMakeFromElems( result, 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( ( quat0->w * quat1->x ) + ( quat0->x * quat1->w ) ) + ( quat0->y * quat1->z ) ) - ( quat0->z * quat1->y ) );
|
||||
tmpY = ( ( ( ( quat0->w * quat1->y ) + ( quat0->y * quat1->w ) ) + ( quat0->z * quat1->x ) ) - ( quat0->x * quat1->z ) );
|
||||
tmpZ = ( ( ( ( quat0->w * quat1->z ) + ( quat0->z * quat1->w ) ) + ( quat0->x * quat1->y ) ) - ( quat0->y * quat1->x ) );
|
||||
tmpW = ( ( ( ( quat0->w * quat1->w ) - ( quat0->x * quat1->x ) ) - ( quat0->y * quat1->y ) ) - ( quat0->z * quat1->z ) );
|
||||
vmathQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat->w * vec->x ) + ( quat->y * vec->z ) ) - ( quat->z * vec->y ) );
|
||||
tmpY = ( ( ( quat->w * vec->y ) + ( quat->z * vec->x ) ) - ( quat->x * vec->z ) );
|
||||
tmpZ = ( ( ( quat->w * vec->z ) + ( quat->x * vec->y ) ) - ( quat->y * vec->x ) );
|
||||
tmpW = ( ( ( quat->x * vec->x ) + ( quat->y * vec->y ) ) + ( quat->z * vec->z ) );
|
||||
result->x = ( ( ( ( tmpW * quat->x ) + ( tmpX * quat->w ) ) - ( tmpY * quat->z ) ) + ( tmpZ * quat->y ) );
|
||||
result->y = ( ( ( ( tmpW * quat->y ) + ( tmpY * quat->w ) ) - ( tmpZ * quat->x ) ) + ( tmpX * quat->z ) );
|
||||
result->z = ( ( ( ( tmpW * quat->z ) + ( tmpZ * quat->w ) ) - ( tmpX * quat->y ) ) + ( tmpY * quat->x ) );
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vmathQMakeFromElems( result, -quat->x, -quat->y, -quat->z, quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
result->x = ( select1 )? quat1->x : quat0->x;
|
||||
result->y = ( select1 )? quat1->y : quat0->y;
|
||||
result->z = ( select1 )? quat1->z : quat0->z;
|
||||
result->w = ( select1 )? quat1->w : quat0->w;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat->x, quat->y, quat->z, quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat->x, quat->y, quat->z, quat->w );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,300 +1,300 @@
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,432 +1,432 @@
|
||||
/*
|
||||
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_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, float _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
start = ( -unitQuat0 );
|
||||
} else {
|
||||
start = unitQuat0;
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX + quat.mX ),
|
||||
( mY + quat.mY ),
|
||||
( mZ + quat.mZ ),
|
||||
( mW + quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX - quat.mX ),
|
||||
( mY - quat.mY ),
|
||||
( mZ - quat.mZ ),
|
||||
( mW - quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX * scalar ),
|
||||
( mY * scalar ),
|
||||
( mZ * scalar ),
|
||||
( mW * scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX / scalar ),
|
||||
( mY / scalar ),
|
||||
( mZ / scalar ),
|
||||
( mW / scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
-mX,
|
||||
-mY,
|
||||
-mZ,
|
||||
-mW
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0.getX() * quat1.getX() );
|
||||
result = ( result + ( quat0.getY() * quat1.getY() ) );
|
||||
result = ( result + ( quat0.getZ() * quat1.getZ() ) );
|
||||
result = ( result + ( quat0.getW() * quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float norm( const Quat & quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat.getX() * quat.getX() );
|
||||
result = ( result + ( quat.getY() * quat.getY() ) );
|
||||
result = ( result + ( quat.getZ() * quat.getZ() ) );
|
||||
result = ( result + ( quat.getW() * quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float length( const Quat & quat )
|
||||
{
|
||||
return sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
return Quat(
|
||||
( quat.getX() * lenInv ),
|
||||
( quat.getY() * lenInv ),
|
||||
( quat.getZ() * lenInv ),
|
||||
( quat.getW() * lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, const Vector3 & unitVec )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ),
|
||||
( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ),
|
||||
( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ),
|
||||
( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) );
|
||||
tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) );
|
||||
tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) );
|
||||
tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) );
|
||||
return Vector3(
|
||||
( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ),
|
||||
( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ),
|
||||
( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 )
|
||||
{
|
||||
return Quat(
|
||||
( select1 )? quat1.getX() : quat0.getX(),
|
||||
( select1 )? quat1.getY() : quat0.getY(),
|
||||
( select1 )? quat1.getZ() : quat0.getZ(),
|
||||
( select1 )? quat1.getW() : quat0.getW()
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, float _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
start = ( -unitQuat0 );
|
||||
} else {
|
||||
start = unitQuat0;
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX + quat.mX ),
|
||||
( mY + quat.mY ),
|
||||
( mZ + quat.mZ ),
|
||||
( mW + quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX - quat.mX ),
|
||||
( mY - quat.mY ),
|
||||
( mZ - quat.mZ ),
|
||||
( mW - quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX * scalar ),
|
||||
( mY * scalar ),
|
||||
( mZ * scalar ),
|
||||
( mW * scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX / scalar ),
|
||||
( mY / scalar ),
|
||||
( mZ / scalar ),
|
||||
( mW / scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
-mX,
|
||||
-mY,
|
||||
-mZ,
|
||||
-mW
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0.getX() * quat1.getX() );
|
||||
result = ( result + ( quat0.getY() * quat1.getY() ) );
|
||||
result = ( result + ( quat0.getZ() * quat1.getZ() ) );
|
||||
result = ( result + ( quat0.getW() * quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float norm( const Quat & quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat.getX() * quat.getX() );
|
||||
result = ( result + ( quat.getY() * quat.getY() ) );
|
||||
result = ( result + ( quat.getZ() * quat.getZ() ) );
|
||||
result = ( result + ( quat.getW() * quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float length( const Quat & quat )
|
||||
{
|
||||
return sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
return Quat(
|
||||
( quat.getX() * lenInv ),
|
||||
( quat.getY() * lenInv ),
|
||||
( quat.getZ() * lenInv ),
|
||||
( quat.getW() * lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, const Vector3 & unitVec )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ),
|
||||
( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ),
|
||||
( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ),
|
||||
( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) );
|
||||
tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) );
|
||||
tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) );
|
||||
tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) );
|
||||
return Vector3(
|
||||
( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ),
|
||||
( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ),
|
||||
( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 )
|
||||
{
|
||||
return Quat(
|
||||
( select1 )? quat1.getX() : quat0.getX(),
|
||||
( select1 )? quat1.getY() : quat0.getY(),
|
||||
( select1 )? quat1.getZ() : quat0.getZ(),
|
||||
( select1 )? quat1.getW() : quat0.getW()
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,371 +1,371 @@
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
result->vec128 = (vec_float4){ _x, _y, _z, _w };
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->vec128 = vec->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->vec128 = spu_splats( scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
|
||||
{
|
||||
result->vec128 = vf4;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
result->vec128 = _VECTORMATH_UNIT_0001;
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.vec128 = spu_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = spu_splats(t);
|
||||
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
|
||||
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
|
||||
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
|
||||
angles = spu_mul( angles, angle );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
|
||||
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
|
||||
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
|
||||
result->vec128 = spu_madd( start.vec128, scale0, spu_mul( unitQuat1->vec128, scale1 ) );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
|
||||
{
|
||||
return quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) );
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
result->vec128 = spu_insert( _x, result->vec128, 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 0 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
result->vec128 = spu_insert( _y, result->vec128, 1 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
result->vec128 = spu_insert( _z, result->vec128, 2 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 2 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
result->vec128 = spu_insert( _w, result->vec128, 3 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 3 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
result->vec128 = spu_insert( value, result->vec128, idx );
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return spu_extract( quat->vec128, idx );
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = spu_add( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = spu_sub( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = spu_mul( quat->vec128, spu_splats(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = divf4( quat->vec128, spu_splats(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = negatef4( quat->vec128 );
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat0->vec128, quat1->vec128 ), 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat->vec128, quat->vec128 ), 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
result->vec128 = spu_mul( quat->vec128, rsqrtf4( dot ) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 crossVec, tmpV3_0;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
|
||||
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
crossVec = tmpV3_0;
|
||||
res = spu_mul( crossVec.vec128, recipCosHalfAngleX2 );
|
||||
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_mul( unitVec->vec128, s ), c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = quat0->vec128;
|
||||
rdata = quat1->vec128;
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
|
||||
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
|
||||
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( ldata, rdata );
|
||||
l_wxyz = spu_rlqwbyte( ldata, 12 );
|
||||
r_wxyz = spu_rlqwbyte( rdata, 12 );
|
||||
qw = spu_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = spu_madd( l_wxyz, r_wxyz, product );
|
||||
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
|
||||
result->vec128 = spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat->vec128;
|
||||
vdata = vec->vec128;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
|
||||
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
|
||||
qv = spu_mul( wwww, vdata );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( qdata, vdata );
|
||||
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
|
||||
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
|
||||
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
|
||||
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
|
||||
res = spu_madd( wwww, qv, res );
|
||||
res = spu_madd( tmp0, tmp1, res );
|
||||
res = spu_nmsub( tmp2, tmp3, res );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = spu_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
result->vec128 = spu_sel( quat0->vec128, quat1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
|
||||
{
|
||||
result->vec128 = (vec_float4){ _x, _y, _z, _w };
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
|
||||
{
|
||||
result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
|
||||
{
|
||||
result->vec128 = vec->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
|
||||
{
|
||||
result->vec128 = spu_splats( scalar );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
|
||||
{
|
||||
result->vec128 = vf4;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeIdentity( VmathQuat *result )
|
||||
{
|
||||
result->vec128 = _VECTORMATH_UNIT_0001;
|
||||
}
|
||||
|
||||
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
VmathQuat tmpQ_0, tmpQ_1;
|
||||
vmathQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
|
||||
{
|
||||
VmathQuat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.vec128 = spu_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = spu_splats(t);
|
||||
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
|
||||
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
|
||||
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
|
||||
angles = spu_mul( angles, angle );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
|
||||
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
|
||||
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
|
||||
result->vec128 = spu_madd( start.vec128, scale0, spu_mul( unitQuat1->vec128, scale1 ) );
|
||||
}
|
||||
|
||||
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
|
||||
{
|
||||
VmathQuat tmp0, tmp1;
|
||||
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
|
||||
{
|
||||
return quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
|
||||
{
|
||||
result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) );
|
||||
}
|
||||
|
||||
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = quat->vec128;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX( VmathQuat *result, float _x )
|
||||
{
|
||||
result->vec128 = spu_insert( _x, result->vec128, 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetX( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 0 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetY( VmathQuat *result, float _y )
|
||||
{
|
||||
result->vec128 = spu_insert( _y, result->vec128, 1 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetY( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 1 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ( VmathQuat *result, float _z )
|
||||
{
|
||||
result->vec128 = spu_insert( _z, result->vec128, 2 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 2 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetW( VmathQuat *result, float _w )
|
||||
{
|
||||
result->vec128 = spu_insert( _w, result->vec128, 3 );
|
||||
}
|
||||
|
||||
static inline float vmathQGetW( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( quat->vec128, 3 );
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
result->vec128 = spu_insert( value, result->vec128, idx );
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
|
||||
{
|
||||
return spu_extract( quat->vec128, idx );
|
||||
}
|
||||
|
||||
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = spu_add( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
result->vec128 = spu_sub( quat0->vec128, quat1->vec128 );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = spu_mul( quat->vec128, spu_splats(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
|
||||
{
|
||||
result->vec128 = divf4( quat->vec128, spu_splats(scalar) );
|
||||
}
|
||||
|
||||
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = negatef4( quat->vec128 );
|
||||
}
|
||||
|
||||
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat0->vec128, quat1->vec128 ), 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQNorm( const VmathQuat *quat )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat->vec128, quat->vec128 ), 0 );
|
||||
}
|
||||
|
||||
static inline float vmathQLength( const VmathQuat *quat )
|
||||
{
|
||||
return sqrtf( vmathQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
|
||||
result->vec128 = spu_mul( quat->vec128, rsqrtf4( dot ) );
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
|
||||
{
|
||||
VmathVector3 crossVec, tmpV3_0;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
|
||||
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
|
||||
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
crossVec = tmpV3_0;
|
||||
res = spu_mul( crossVec.vec128, recipCosHalfAngleX2 );
|
||||
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_mul( unitVec->vec128, s ), c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = quat0->vec128;
|
||||
rdata = quat1->vec128;
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
|
||||
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
|
||||
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( ldata, rdata );
|
||||
l_wxyz = spu_rlqwbyte( ldata, 12 );
|
||||
r_wxyz = spu_rlqwbyte( rdata, 12 );
|
||||
qw = spu_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = spu_madd( l_wxyz, r_wxyz, product );
|
||||
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
|
||||
result->vec128 = spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) );
|
||||
}
|
||||
|
||||
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat->vec128;
|
||||
vdata = vec->vec128;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
|
||||
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
|
||||
qv = spu_mul( wwww, vdata );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( qdata, vdata );
|
||||
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
|
||||
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
|
||||
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
|
||||
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
|
||||
res = spu_madd( wwww, qv, res );
|
||||
res = spu_madd( tmp0, tmp1, res );
|
||||
res = spu_nmsub( tmp2, tmp3, res );
|
||||
result->vec128 = res;
|
||||
}
|
||||
|
||||
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
result->vec128 = spu_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
|
||||
}
|
||||
|
||||
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
|
||||
{
|
||||
result->vec128 = spu_sel( quat0->vec128, quat1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint( const VmathQuat *quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat->vec128;
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,312 +1,312 @@
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFrom128(&result, vf4);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGet128(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_V_C_H
|
||||
#define _VECTORMATH_QUAT_AOS_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeFrom128(&result, vf4);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeIdentity_V( )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGet128(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
|
||||
{
|
||||
vmathQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathQSetX_V( VmathQuat *result, float _x )
|
||||
{
|
||||
vmathQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline float vmathQGetX_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetY_V( VmathQuat *result, float _y )
|
||||
{
|
||||
vmathQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline float vmathQGetY_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
|
||||
{
|
||||
vmathQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline float vmathQGetZ_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetW_V( VmathQuat *result, float _w )
|
||||
{
|
||||
vmathQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline float vmathQGetW_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
|
||||
{
|
||||
vmathQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
|
||||
{
|
||||
return vmathQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
return vmathQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline float vmathQNorm_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline float vmathQLength_V( VmathQuat quat )
|
||||
{
|
||||
return vmathQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationX_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationY_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
|
||||
{
|
||||
VmathVector3 result;
|
||||
vmathQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQConj_V( VmathQuat quat )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
|
||||
{
|
||||
VmathQuat result;
|
||||
vmathQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathQPrint_V( VmathQuat quat )
|
||||
{
|
||||
vmathQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
|
||||
{
|
||||
vmathQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,419 +1,419 @@
|
||||
/*
|
||||
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_QUAT_SOA_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetXYZ( result, xyz );
|
||||
vmathSoaQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
vec_float4 vec128 = quat->vec128;
|
||||
result->x = spu_shuffle( vec128, vec128, shuffle_xxxx );
|
||||
result->y = spu_shuffle( vec128, vec128, shuffle_yyyy );
|
||||
result->z = spu_shuffle( vec128, vec128, shuffle_zzzz );
|
||||
result->w = spu_shuffle( vec128, vec128, shuffle_wwww );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_ZCWD );
|
||||
result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
|
||||
result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
|
||||
result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
|
||||
result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
VmathSoaQuat tmpQ_0, tmpQ_1;
|
||||
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathSoaQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat start, tmpQ_0, tmpQ_1;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
vmathSoaQSetX( &start, spu_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
|
||||
vmathSoaQSetY( &start, spu_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
|
||||
vmathSoaQSetZ( &start, spu_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
|
||||
vmathSoaQSetW( &start, spu_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = recipf4( sinf4( angle ) );
|
||||
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
|
||||
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
|
||||
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat tmp0, tmp1;
|
||||
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathSoaQSlerp( result, spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_ZCWD );
|
||||
vmathQMakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
|
||||
vmathQMakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
|
||||
vmathQMakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
|
||||
vmathQMakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = spu_add( quat0->x, quat1->x );
|
||||
result->y = spu_add( quat0->y, quat1->y );
|
||||
result->z = spu_add( quat0->z, quat1->z );
|
||||
result->w = spu_add( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = spu_sub( quat0->x, quat1->x );
|
||||
result->y = spu_sub( quat0->y, quat1->y );
|
||||
result->z = spu_sub( quat0->z, quat1->z );
|
||||
result->w = spu_sub( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = spu_mul( quat->x, scalar );
|
||||
result->y = spu_mul( quat->y, scalar );
|
||||
result->z = spu_mul( quat->z, scalar );
|
||||
result->w = spu_mul( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = divf4( quat->x, scalar );
|
||||
result->y = divf4( quat->y, scalar );
|
||||
result->z = divf4( quat->z, scalar );
|
||||
result->w = divf4( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = negatef4( quat->x );
|
||||
result->y = negatef4( quat->y );
|
||||
result->z = negatef4( quat->z );
|
||||
result->w = negatef4( quat->w );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat0->x, quat1->x );
|
||||
result = spu_add( result, spu_mul( quat0->y, quat1->y ) );
|
||||
result = spu_add( result, spu_mul( quat0->z, quat1->z ) );
|
||||
result = spu_add( result, spu_mul( quat0->w, quat1->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat->x, quat->x );
|
||||
result = spu_add( result, spu_mul( quat->y, quat->y ) );
|
||||
result = spu_add( result, spu_mul( quat->z, quat->z ) );
|
||||
result = spu_add( result, spu_mul( quat->w, quat->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
|
||||
{
|
||||
return sqrtf4( vmathSoaQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = vmathSoaQNorm( quat );
|
||||
lenInv = rsqrtf4( lenSqr );
|
||||
result->x = spu_mul( quat->x, lenInv );
|
||||
result->y = spu_mul( quat->y, lenInv );
|
||||
result->z = spu_mul( quat->z, lenInv );
|
||||
result->w = spu_mul( quat->w, lenInv );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0, tmpV3_1;
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), vmathSoaV3Dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
|
||||
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0;
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, s, spu_splats(0.0f), spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), s, spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), s, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->x ), spu_mul( quat0->x, quat1->w ) ), spu_mul( quat0->y, quat1->z ) ), spu_mul( quat0->z, quat1->y ) );
|
||||
tmpY = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->y ), spu_mul( quat0->y, quat1->w ) ), spu_mul( quat0->z, quat1->x ) ), spu_mul( quat0->x, quat1->z ) );
|
||||
tmpZ = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->z ), spu_mul( quat0->z, quat1->w ) ), spu_mul( quat0->x, quat1->y ) ), spu_mul( quat0->y, quat1->x ) );
|
||||
tmpW = spu_sub( spu_sub( spu_sub( spu_mul( quat0->w, quat1->w ), spu_mul( quat0->x, quat1->x ) ), spu_mul( quat0->y, quat1->y ) ), spu_mul( quat0->z, quat1->z ) );
|
||||
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_mul( quat->w, vec->x ), spu_mul( quat->y, vec->z ) ), spu_mul( quat->z, vec->y ) );
|
||||
tmpY = spu_sub( spu_add( spu_mul( quat->w, vec->y ), spu_mul( quat->z, vec->x ) ), spu_mul( quat->x, vec->z ) );
|
||||
tmpZ = spu_sub( spu_add( spu_mul( quat->w, vec->z ), spu_mul( quat->x, vec->y ) ), spu_mul( quat->y, vec->x ) );
|
||||
tmpW = spu_add( spu_add( spu_mul( quat->x, vec->x ), spu_mul( quat->y, vec->y ) ), spu_mul( quat->z, vec->z ) );
|
||||
result->x = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->x ), spu_mul( tmpX, quat->w ) ), spu_mul( tmpY, quat->z ) ), spu_mul( tmpZ, quat->y ) );
|
||||
result->y = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->y ), spu_mul( tmpY, quat->w ) ), spu_mul( tmpZ, quat->x ) ), spu_mul( tmpX, quat->z ) );
|
||||
result->z = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->z ), spu_mul( tmpZ, quat->w ) ), spu_mul( tmpX, quat->y ) ), spu_mul( tmpY, quat->x ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
|
||||
{
|
||||
result->x = spu_sel( quat0->x, quat1->x, select1 );
|
||||
result->y = spu_sel( quat0->y, quat1->y, select1 );
|
||||
result->z = spu_sel( quat0->z, quat1->z, select1 );
|
||||
result->w = spu_sel( quat0->w, quat1->w, select1 );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = quat->x;
|
||||
result->y = quat->y;
|
||||
result->z = quat->z;
|
||||
result->w = quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
result->x = _x;
|
||||
result->y = _y;
|
||||
result->z = _z;
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetXYZ( result, xyz );
|
||||
vmathSoaQSetW( result, _w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
result->w = vec->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
|
||||
{
|
||||
result->x = scalar;
|
||||
result->y = scalar;
|
||||
result->z = scalar;
|
||||
result->w = scalar;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
|
||||
{
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
vec_float4 vec128 = quat->vec128;
|
||||
result->x = spu_shuffle( vec128, vec128, shuffle_xxxx );
|
||||
result->y = spu_shuffle( vec128, vec128, shuffle_yyyy );
|
||||
result->z = spu_shuffle( vec128, vec128, shuffle_zzzz );
|
||||
result->w = spu_shuffle( vec128, vec128, shuffle_wwww );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_ZCWD );
|
||||
result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
|
||||
result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
|
||||
result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
|
||||
result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
VmathSoaQuat tmpQ_0, tmpQ_1;
|
||||
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
|
||||
vmathSoaQAdd( result, quat0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat start, tmpQ_0, tmpQ_1;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
vmathSoaQSetX( &start, spu_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
|
||||
vmathSoaQSetY( &start, spu_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
|
||||
vmathSoaQSetZ( &start, spu_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
|
||||
vmathSoaQSetW( &start, spu_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = recipf4( sinf4( angle ) );
|
||||
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
|
||||
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
|
||||
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
|
||||
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
|
||||
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat tmp0, tmp1;
|
||||
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
|
||||
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
|
||||
vmathSoaQSlerp( result, spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), &tmp0, &tmp1 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_ZCWD );
|
||||
vmathQMakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
|
||||
vmathQMakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
|
||||
vmathQMakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
|
||||
vmathQMakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
|
||||
{
|
||||
result->x = vec->x;
|
||||
result->y = vec->y;
|
||||
result->z = vec->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
result->x = _x;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->x;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
result->y = _y;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->y;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
result->z = _z;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->z;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
result->w = _w;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
|
||||
{
|
||||
return quat->w;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
*(&result->x + idx) = value;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
|
||||
{
|
||||
return *(&quat->x + idx);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = spu_add( quat0->x, quat1->x );
|
||||
result->y = spu_add( quat0->y, quat1->y );
|
||||
result->z = spu_add( quat0->z, quat1->z );
|
||||
result->w = spu_add( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
result->x = spu_sub( quat0->x, quat1->x );
|
||||
result->y = spu_sub( quat0->y, quat1->y );
|
||||
result->z = spu_sub( quat0->z, quat1->z );
|
||||
result->w = spu_sub( quat0->w, quat1->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = spu_mul( quat->x, scalar );
|
||||
result->y = spu_mul( quat->y, scalar );
|
||||
result->z = spu_mul( quat->z, scalar );
|
||||
result->w = spu_mul( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
|
||||
{
|
||||
result->x = divf4( quat->x, scalar );
|
||||
result->y = divf4( quat->y, scalar );
|
||||
result->z = divf4( quat->z, scalar );
|
||||
result->w = divf4( quat->w, scalar );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
result->x = negatef4( quat->x );
|
||||
result->y = negatef4( quat->y );
|
||||
result->z = negatef4( quat->z );
|
||||
result->w = negatef4( quat->w );
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat0->x, quat1->x );
|
||||
result = spu_add( result, spu_mul( quat0->y, quat1->y ) );
|
||||
result = spu_add( result, spu_mul( quat0->z, quat1->z ) );
|
||||
result = spu_add( result, spu_mul( quat0->w, quat1->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat->x, quat->x );
|
||||
result = spu_add( result, spu_mul( quat->y, quat->y ) );
|
||||
result = spu_add( result, spu_mul( quat->z, quat->z ) );
|
||||
result = spu_add( result, spu_mul( quat->w, quat->w ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
|
||||
{
|
||||
return sqrtf4( vmathSoaQNorm( quat ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = vmathSoaQNorm( quat );
|
||||
lenInv = rsqrtf4( lenSqr );
|
||||
result->x = spu_mul( quat->x, lenInv );
|
||||
result->y = spu_mul( quat->y, lenInv );
|
||||
result->z = spu_mul( quat->z, lenInv );
|
||||
result->w = spu_mul( quat->w, lenInv );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0, tmpV3_1;
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), vmathSoaV3Dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
|
||||
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
|
||||
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
|
||||
{
|
||||
VmathSoaVector3 tmpV3_0;
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
|
||||
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, s, spu_splats(0.0f), spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), s, spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), s, c );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->x ), spu_mul( quat0->x, quat1->w ) ), spu_mul( quat0->y, quat1->z ) ), spu_mul( quat0->z, quat1->y ) );
|
||||
tmpY = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->y ), spu_mul( quat0->y, quat1->w ) ), spu_mul( quat0->z, quat1->x ) ), spu_mul( quat0->x, quat1->z ) );
|
||||
tmpZ = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->z ), spu_mul( quat0->z, quat1->w ) ), spu_mul( quat0->x, quat1->y ) ), spu_mul( quat0->y, quat1->x ) );
|
||||
tmpW = spu_sub( spu_sub( spu_sub( spu_mul( quat0->w, quat1->w ), spu_mul( quat0->x, quat1->x ) ), spu_mul( quat0->y, quat1->y ) ), spu_mul( quat0->z, quat1->z ) );
|
||||
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_mul( quat->w, vec->x ), spu_mul( quat->y, vec->z ) ), spu_mul( quat->z, vec->y ) );
|
||||
tmpY = spu_sub( spu_add( spu_mul( quat->w, vec->y ), spu_mul( quat->z, vec->x ) ), spu_mul( quat->x, vec->z ) );
|
||||
tmpZ = spu_sub( spu_add( spu_mul( quat->w, vec->z ), spu_mul( quat->x, vec->y ) ), spu_mul( quat->y, vec->x ) );
|
||||
tmpW = spu_add( spu_add( spu_mul( quat->x, vec->x ), spu_mul( quat->y, vec->y ) ), spu_mul( quat->z, vec->z ) );
|
||||
result->x = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->x ), spu_mul( tmpX, quat->w ) ), spu_mul( tmpY, quat->z ) ), spu_mul( tmpZ, quat->y ) );
|
||||
result->y = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->y ), spu_mul( tmpY, quat->w ) ), spu_mul( tmpZ, quat->x ) ), spu_mul( tmpX, quat->z ) );
|
||||
result->z = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->z ), spu_mul( tmpZ, quat->w ) ), spu_mul( tmpX, quat->y ) ), spu_mul( tmpY, quat->x ) );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
|
||||
{
|
||||
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
|
||||
{
|
||||
result->x = spu_sel( quat0->x, quat1->x, select1 );
|
||||
result->y = spu_sel( quat0->y, quat1->y, select1 );
|
||||
result->z = spu_sel( quat0->z, quat1->z, select1 );
|
||||
result->w = spu_sel( quat0->w, quat1->w, select1 );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
|
||||
{
|
||||
VmathQuat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
|
||||
printf("slot 0:\n");
|
||||
vmathQPrint( &vec0 );
|
||||
printf("slot 1:\n");
|
||||
vmathQPrint( &vec1 );
|
||||
printf("slot 2:\n");
|
||||
vmathQPrint( &vec2 );
|
||||
printf("slot 3:\n");
|
||||
vmathQPrint( &vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,319 +1,319 @@
|
||||
/*
|
||||
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_QUAT_SOA_V_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromAos(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
|
||||
{
|
||||
vmathSoaQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
vmathSoaQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
vmathSoaQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
vmathSoaQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
vmathSoaQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
|
||||
{
|
||||
return vmathSoaQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
return vmathSoaQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
|
||||
{
|
||||
vmathSoaQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
|
||||
{
|
||||
vmathSoaQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_V_C_H
|
||||
#define _VECTORMATH_QUAT_SOA_V_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*/
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromV4(&result, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromScalar(&result, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFromAos(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeIdentity(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQLerp(&result, t, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
|
||||
{
|
||||
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
|
||||
{
|
||||
vmathSoaQSetXYZ(result, &vec);
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQGetXYZ(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
|
||||
{
|
||||
vmathSoaQSetX(result, _x);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetX(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
|
||||
{
|
||||
vmathSoaQSetY(result, _y);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetY(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
|
||||
{
|
||||
vmathSoaQSetZ(result, _z);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetZ(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
|
||||
{
|
||||
vmathSoaQSetW(result, _w);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQGetW(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
|
||||
{
|
||||
vmathSoaQSetElem(result, idx, value);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
|
||||
{
|
||||
return vmathSoaQGetElem(&quat, idx);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQAdd(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSub(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarMul(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQScalarDiv(&result, &quat, scalar);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNeg(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
return vmathSoaQDot(&quat0, &quat1);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQNorm(&quat);
|
||||
}
|
||||
|
||||
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
|
||||
{
|
||||
return vmathSoaQLength(&quat);
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQNormalize(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationX(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationY(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMakeRotationZ(&result, radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQMul(&result, &quat0, &quat1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
|
||||
{
|
||||
VmathSoaVector3 result;
|
||||
vmathSoaQRotate(&result, &quat, &vec);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQConj(&result, &quat);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
|
||||
{
|
||||
VmathSoaQuat result;
|
||||
vmathSoaQSelect(&result, &quat0, &quat1, select1);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
|
||||
{
|
||||
vmathSoaQPrint(&quat);
|
||||
}
|
||||
|
||||
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
|
||||
{
|
||||
vmathSoaQPrints(&quat, name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,246 +1,246 @@
|
||||
/*
|
||||
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 _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <spu_intrinsics.h>
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
vec_uint4 mData;
|
||||
|
||||
inline boolInVec(vec_uint4 vec);
|
||||
public:
|
||||
inline boolInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
#else
|
||||
// implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// bool value is in the 0 word slot of vector as 0 (false) or -1 (true)
|
||||
//
|
||||
inline vec_uint4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(vec_uint4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
mData = spu_promote((unsigned int)-scalar, 0);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
#else
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
#endif
|
||||
{
|
||||
return (bool)spu_extract(mData, 0);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_uint4
|
||||
boolInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(spu_nor(mData, mData));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_and(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_or(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_xor(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
/*
|
||||
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 _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <spu_intrinsics.h>
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
vec_uint4 mData;
|
||||
|
||||
inline boolInVec(vec_uint4 vec);
|
||||
public:
|
||||
inline boolInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
#else
|
||||
// implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// bool value is in the 0 word slot of vector as 0 (false) or -1 (true)
|
||||
//
|
||||
inline vec_uint4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(vec_uint4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
mData = spu_promote((unsigned int)-scalar, 0);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
#else
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
#endif
|
||||
{
|
||||
return (bool)spu_extract(mData, 0);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_uint4
|
||||
boolInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(spu_nor(mData, mData));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_and(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_or(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_xor(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
|
||||
@@ -1,340 +1,339 @@
|
||||
/*
|
||||
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 _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <spu_intrinsics.h>
|
||||
#include "spu2vmx.h"
|
||||
#include "simdmath.h"
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
vec_float4 mData;
|
||||
|
||||
inline floatInVec(vec_float4 vec);
|
||||
public:
|
||||
inline floatInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// construct from a slot of vec_float4
|
||||
//
|
||||
inline floatInVec(vec_float4 vec, int slot);
|
||||
|
||||
// explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
// implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// float value is in 0 word slot of vector
|
||||
//
|
||||
inline vec_float4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
inline const floatInVec operator -- (int);
|
||||
inline floatInVec& operator ++ ();
|
||||
inline floatInVec& operator -- ();
|
||||
inline const floatInVec operator - () const;
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128());
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec, int slot)
|
||||
{
|
||||
mData = spu_promote(spu_extract(vec, slot), 0);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
mData = spu_promote(scalar, 0);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
#else
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
#endif
|
||||
{
|
||||
return spu_extract(mData,0);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_float4
|
||||
floatInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000)));
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_mul(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(divf4(num.get128(), den.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_add(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_sub(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
/*
|
||||
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 _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <spu_intrinsics.h>
|
||||
#include <simdmath.h>
|
||||
#undef bool
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
vec_float4 mData;
|
||||
|
||||
inline floatInVec(vec_float4 vec);
|
||||
public:
|
||||
inline floatInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// construct from a slot of vec_float4
|
||||
//
|
||||
inline floatInVec(vec_float4 vec, int slot);
|
||||
|
||||
// explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
// implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// float value is in 0 word slot of vector
|
||||
//
|
||||
inline vec_float4 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
inline const floatInVec operator -- (int);
|
||||
inline floatInVec& operator ++ ();
|
||||
inline floatInVec& operator -- ();
|
||||
inline const floatInVec operator - () const;
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128());
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(vec_float4 vec, int slot)
|
||||
{
|
||||
mData = spu_promote(spu_extract(vec, slot), 0);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
mData = spu_promote(scalar, 0);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
#else
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
#endif
|
||||
{
|
||||
return spu_extract(mData,0);
|
||||
}
|
||||
|
||||
inline
|
||||
vec_float4
|
||||
floatInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
vec_float4 olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000)));
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_mul(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(divf4(num.get128(), den.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_add(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(spu_sub(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,417 +1,417 @@
|
||||
/*
|
||||
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_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mVec128 = (vec_float4){ _x, _y, _z, _w };
|
||||
}
|
||||
|
||||
inline Quat::Quat( Vector3 xyz, float _w )
|
||||
{
|
||||
mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Vector4 vec )
|
||||
{
|
||||
mVec128 = vec.get128();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
mVec128 = spu_splats( scalar );
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 vf4 )
|
||||
{
|
||||
mVec128 = vf4;
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( _VECTORMATH_UNIT_0001 );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, Quat quat0, Quat quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start = Quat( spu_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = spu_splats(t);
|
||||
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
|
||||
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
|
||||
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
|
||||
angles = spu_mul( angles, angle );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
|
||||
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
|
||||
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
|
||||
return Quat( spu_madd( start.get128(), scale0, spu_mul( unitQuat1.get128(), scale1 ) ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::get128( ) const
|
||||
{
|
||||
return mVec128;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( Quat quat )
|
||||
{
|
||||
mVec128 = quat.mVec128;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( Vector3 vec )
|
||||
{
|
||||
mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mVec128 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mVec128 = spu_insert( _x, mVec128, 0 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 0 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mVec128 = spu_insert( _y, mVec128, 1 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 1 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mVec128 = spu_insert( _z, mVec128, 2 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 2 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mVec128 = spu_insert( _w, mVec128, 3 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 3 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
mVec128 = spu_insert( value, mVec128, idx );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return spu_extract( mVec128, idx );
|
||||
}
|
||||
|
||||
inline VecIdx Quat::operator []( int idx )
|
||||
{
|
||||
return VecIdx( mVec128, idx );
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return spu_extract( mVec128, idx );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( Quat quat ) const
|
||||
{
|
||||
return Quat( spu_add( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( Quat quat ) const
|
||||
{
|
||||
return Quat( spu_sub( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return Quat( spu_mul( mVec128, spu_splats(scalar) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( Quat quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( Quat quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat( divf4( mVec128, spu_splats(scalar) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat( negatef4( mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, Quat quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( Quat quat0, Quat quat1 )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 );
|
||||
}
|
||||
|
||||
inline float norm( Quat quat )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat.get128(), quat.get128() ), 0 );
|
||||
}
|
||||
|
||||
inline float length( Quat quat )
|
||||
{
|
||||
return sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( Quat quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() );
|
||||
return Quat( spu_mul( quat.get128(), rsqrtf4( dot ) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 )
|
||||
{
|
||||
Vector3 crossVec;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
|
||||
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
|
||||
crossVec = cross( unitVec0, unitVec1 );
|
||||
res = spu_mul( crossVec.get128(), recipCosHalfAngleX2 );
|
||||
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, Vector3 unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_mul( unitVec.get128(), s ), c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( Quat quat ) const
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = mVec128;
|
||||
rdata = quat.mVec128;
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
|
||||
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
|
||||
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( ldata, rdata );
|
||||
l_wxyz = spu_rlqwbyte( ldata, 12 );
|
||||
r_wxyz = spu_rlqwbyte( rdata, 12 );
|
||||
qw = spu_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = spu_madd( l_wxyz, r_wxyz, product );
|
||||
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
|
||||
return Quat( spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( Quat quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( Quat quat, Vector3 vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat.get128();
|
||||
vdata = vec.get128();
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
|
||||
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
|
||||
qv = spu_mul( wwww, vdata );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( qdata, vdata );
|
||||
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
|
||||
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
|
||||
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
|
||||
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
|
||||
res = spu_madd( wwww, qv, res );
|
||||
res = spu_madd( tmp0, tmp1, res );
|
||||
res = spu_nmsub( tmp2, tmp3, res );
|
||||
return Vector3( res );
|
||||
}
|
||||
|
||||
inline const Quat conj( Quat quat )
|
||||
{
|
||||
return Quat( spu_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) );
|
||||
}
|
||||
|
||||
inline const Quat select( Quat quat0, Quat quat1, bool select1 )
|
||||
{
|
||||
return Quat( spu_sel( quat0.get128(), quat1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( Quat quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
inline void print( Quat quat, const char * name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mVec128 = (vec_float4){ _x, _y, _z, _w };
|
||||
}
|
||||
|
||||
inline Quat::Quat( Vector3 xyz, float _w )
|
||||
{
|
||||
mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Vector4 vec )
|
||||
{
|
||||
mVec128 = vec.get128();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
mVec128 = spu_splats( scalar );
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 vf4 )
|
||||
{
|
||||
mVec128 = vf4;
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( _VECTORMATH_UNIT_0001 );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, Quat quat0, Quat quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
vec_uint4 selectMask;
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start = Quat( spu_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = spu_splats(t);
|
||||
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
|
||||
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
|
||||
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
|
||||
angles = spu_mul( angles, angle );
|
||||
sines = sinf4( angles );
|
||||
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
|
||||
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
|
||||
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
|
||||
return Quat( spu_madd( start.get128(), scale0, spu_mul( unitQuat1.get128(), scale1 ) ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::get128( ) const
|
||||
{
|
||||
return mVec128;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( Quat quat )
|
||||
{
|
||||
mVec128 = quat.mVec128;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( Vector3 vec )
|
||||
{
|
||||
mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mVec128 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mVec128 = spu_insert( _x, mVec128, 0 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 0 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mVec128 = spu_insert( _y, mVec128, 1 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 1 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mVec128 = spu_insert( _z, mVec128, 2 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 2 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mVec128 = spu_insert( _w, mVec128, 3 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return spu_extract( mVec128, 3 );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
mVec128 = spu_insert( value, mVec128, idx );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return spu_extract( mVec128, idx );
|
||||
}
|
||||
|
||||
inline VecIdx Quat::operator []( int idx )
|
||||
{
|
||||
return VecIdx( mVec128, idx );
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return spu_extract( mVec128, idx );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( Quat quat ) const
|
||||
{
|
||||
return Quat( spu_add( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( Quat quat ) const
|
||||
{
|
||||
return Quat( spu_sub( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return Quat( spu_mul( mVec128, spu_splats(scalar) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( Quat quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( Quat quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat( divf4( mVec128, spu_splats(scalar) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat( negatef4( mVec128 ) );
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, Quat quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( Quat quat0, Quat quat1 )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 );
|
||||
}
|
||||
|
||||
inline float norm( Quat quat )
|
||||
{
|
||||
return spu_extract( _vmathVfDot4( quat.get128(), quat.get128() ), 0 );
|
||||
}
|
||||
|
||||
inline float length( Quat quat )
|
||||
{
|
||||
return sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( Quat quat )
|
||||
{
|
||||
vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() );
|
||||
return Quat( spu_mul( quat.get128(), rsqrtf4( dot ) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 )
|
||||
{
|
||||
Vector3 crossVec;
|
||||
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() );
|
||||
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
|
||||
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
|
||||
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
|
||||
crossVec = cross( unitVec0, unitVec1 );
|
||||
res = spu_mul( crossVec.get128(), recipCosHalfAngleX2 );
|
||||
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, Vector3 unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_mul( unitVec.get128(), s ), c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
vec_float4 s, c, angle, res;
|
||||
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
|
||||
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( Quat quat ) const
|
||||
{
|
||||
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = mVec128;
|
||||
rdata = quat.mVec128;
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
|
||||
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
|
||||
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( ldata, rdata );
|
||||
l_wxyz = spu_rlqwbyte( ldata, 12 );
|
||||
r_wxyz = spu_rlqwbyte( rdata, 12 );
|
||||
qw = spu_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = spu_madd( l_wxyz, r_wxyz, product );
|
||||
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
|
||||
return Quat( spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( Quat quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( Quat quat, Vector3 vec )
|
||||
{
|
||||
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat.get128();
|
||||
vdata = vec.get128();
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
|
||||
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
|
||||
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
|
||||
qv = spu_mul( wwww, vdata );
|
||||
qv = spu_madd( tmp0, tmp1, qv );
|
||||
qv = spu_nmsub( tmp2, tmp3, qv );
|
||||
product = spu_mul( qdata, vdata );
|
||||
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
|
||||
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
|
||||
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
|
||||
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
|
||||
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
|
||||
res = spu_madd( wwww, qv, res );
|
||||
res = spu_madd( tmp0, tmp1, res );
|
||||
res = spu_nmsub( tmp2, tmp3, res );
|
||||
return Vector3( res );
|
||||
}
|
||||
|
||||
inline const Quat conj( Quat quat )
|
||||
{
|
||||
return Quat( spu_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) );
|
||||
}
|
||||
|
||||
inline const Quat select( Quat quat0, Quat quat1, bool select1 )
|
||||
{
|
||||
return Quat( spu_sel( quat0.get128(), quat1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) );
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( Quat quat )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
inline void print( Quat quat, const char * name )
|
||||
{
|
||||
union { vec_float4 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,483 +1,483 @@
|
||||
/*
|
||||
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_QUAT_SOA_CPP_H
|
||||
#define _VECTORMATH_QUAT_SOA_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Soa {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat )
|
||||
{
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
vec_float4 vec128 = quat.get128();
|
||||
mX = spu_shuffle( vec128, vec128, shuffle_xxxx );
|
||||
mY = spu_shuffle( vec128, vec128, shuffle_yyyy );
|
||||
mZ = spu_shuffle( vec128, vec128, shuffle_zzzz );
|
||||
mW = spu_shuffle( vec128, vec128, shuffle_wwww );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_ZCWD );
|
||||
mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
|
||||
mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
|
||||
mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
|
||||
mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
|
||||
}
|
||||
|
||||
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.setX( spu_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
|
||||
start.setY( spu_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
|
||||
start.setZ( spu_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
|
||||
start.setW( spu_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = recipf4( sinf4( angle ) );
|
||||
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
|
||||
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD );
|
||||
result0 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
|
||||
result1 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
|
||||
result2 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
|
||||
result3 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( vec_float4 _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( vec_float4 _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( vec_float4 _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( vec_float4 _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, vec_float4 value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline Quat::vec_float4_t & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_add( mX, quat.mX ),
|
||||
spu_add( mY, quat.mY ),
|
||||
spu_add( mZ, quat.mZ ),
|
||||
spu_add( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_sub( mX, quat.mX ),
|
||||
spu_sub( mY, quat.mY ),
|
||||
spu_sub( mZ, quat.mZ ),
|
||||
spu_sub( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_mul( mX, scalar ),
|
||||
spu_mul( mY, scalar ),
|
||||
spu_mul( mZ, scalar ),
|
||||
spu_mul( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
divf4( mX, scalar ),
|
||||
divf4( mY, scalar ),
|
||||
divf4( mZ, scalar ),
|
||||
divf4( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
negatef4( mX ),
|
||||
negatef4( mY ),
|
||||
negatef4( mZ ),
|
||||
negatef4( mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat0.getX(), quat1.getX() );
|
||||
result = spu_add( result, spu_mul( quat0.getY(), quat1.getY() ) );
|
||||
result = spu_add( result, spu_mul( quat0.getZ(), quat1.getZ() ) );
|
||||
result = spu_add( result, spu_mul( quat0.getW(), quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 norm( const Quat & quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat.getX(), quat.getX() );
|
||||
result = spu_add( result, spu_mul( quat.getY(), quat.getY() ) );
|
||||
result = spu_add( result, spu_mul( quat.getZ(), quat.getZ() ) );
|
||||
result = spu_add( result, spu_mul( quat.getW(), quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 length( const Quat & quat )
|
||||
{
|
||||
return sqrtf4( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = rsqrtf4( lenSqr );
|
||||
return Quat(
|
||||
spu_mul( quat.getX(), lenInv ),
|
||||
spu_mul( quat.getY(), lenInv ),
|
||||
spu_mul( quat.getZ(), lenInv ),
|
||||
spu_mul( quat.getW(), lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( s, spu_splats(0.0f), spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( spu_splats(0.0f), s, spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( spu_splats(0.0f), spu_splats(0.0f), s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mX ), spu_mul( mX, quat.mW ) ), spu_mul( mY, quat.mZ ) ), spu_mul( mZ, quat.mY ) ),
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mY ), spu_mul( mY, quat.mW ) ), spu_mul( mZ, quat.mX ) ), spu_mul( mX, quat.mZ ) ),
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mZ ), spu_mul( mZ, quat.mW ) ), spu_mul( mX, quat.mY ) ), spu_mul( mY, quat.mX ) ),
|
||||
spu_sub( spu_sub( spu_sub( spu_mul( mW, quat.mW ), spu_mul( mX, quat.mX ) ), spu_mul( mY, quat.mY ) ), spu_mul( mZ, quat.mZ ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_mul( quat.getW(), vec.getX() ), spu_mul( quat.getY(), vec.getZ() ) ), spu_mul( quat.getZ(), vec.getY() ) );
|
||||
tmpY = spu_sub( spu_add( spu_mul( quat.getW(), vec.getY() ), spu_mul( quat.getZ(), vec.getX() ) ), spu_mul( quat.getX(), vec.getZ() ) );
|
||||
tmpZ = spu_sub( spu_add( spu_mul( quat.getW(), vec.getZ() ), spu_mul( quat.getX(), vec.getY() ) ), spu_mul( quat.getY(), vec.getX() ) );
|
||||
tmpW = spu_add( spu_add( spu_mul( quat.getX(), vec.getX() ), spu_mul( quat.getY(), vec.getY() ) ), spu_mul( quat.getZ(), vec.getZ() ) );
|
||||
return Vector3(
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getX() ), spu_mul( tmpX, quat.getW() ) ), spu_mul( tmpY, quat.getZ() ) ), spu_mul( tmpZ, quat.getY() ) ),
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getY() ), spu_mul( tmpY, quat.getW() ) ), spu_mul( tmpZ, quat.getX() ) ), spu_mul( tmpX, quat.getZ() ) ),
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getZ() ), spu_mul( tmpZ, quat.getW() ) ), spu_mul( tmpX, quat.getY() ) ), spu_mul( tmpY, quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
|
||||
{
|
||||
return Quat(
|
||||
spu_sel( quat0.getX(), quat1.getX(), select1 ),
|
||||
spu_sel( quat0.getY(), quat1.getY(), select1 ),
|
||||
spu_sel( quat0.getZ(), quat1.getZ(), select1 ),
|
||||
spu_sel( quat0.getW(), quat1.getW(), select1 )
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Soa
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_QUAT_SOA_CPP_H
|
||||
#define _VECTORMATH_QUAT_SOA_CPP_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Soa {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( vec_float4 scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat )
|
||||
{
|
||||
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
|
||||
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
|
||||
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
|
||||
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
|
||||
vec_float4 vec128 = quat.get128();
|
||||
mX = spu_shuffle( vec128, vec128, shuffle_xxxx );
|
||||
mY = spu_shuffle( vec128, vec128, shuffle_yyyy );
|
||||
mZ = spu_shuffle( vec128, vec128, shuffle_zzzz );
|
||||
mW = spu_shuffle( vec128, vec128, shuffle_wwww );
|
||||
}
|
||||
|
||||
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_ZCWD );
|
||||
mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
|
||||
mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
|
||||
mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
|
||||
mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
|
||||
}
|
||||
|
||||
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
vec_uint4 selectMask;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
|
||||
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start.setX( spu_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
|
||||
start.setY( spu_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
|
||||
start.setZ( spu_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
|
||||
start.setW( spu_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
|
||||
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
recipSinAngle = recipf4( sinf4( angle ) );
|
||||
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
|
||||
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
|
||||
{
|
||||
vec_float4 tmp0, tmp1, tmp2, tmp3;
|
||||
tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB );
|
||||
tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB );
|
||||
tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD );
|
||||
tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD );
|
||||
result0 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
|
||||
result1 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
|
||||
result2 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
|
||||
result3 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( vec_float4 _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( vec_float4 _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( vec_float4 _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( vec_float4 _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, vec_float4 value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline Quat::vec_float4_t & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline vec_float4 Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_add( mX, quat.mX ),
|
||||
spu_add( mY, quat.mY ),
|
||||
spu_add( mZ, quat.mZ ),
|
||||
spu_add( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_sub( mX, quat.mX ),
|
||||
spu_sub( mY, quat.mY ),
|
||||
spu_sub( mZ, quat.mZ ),
|
||||
spu_sub( mW, quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_mul( mX, scalar ),
|
||||
spu_mul( mY, scalar ),
|
||||
spu_mul( mZ, scalar ),
|
||||
spu_mul( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( vec_float4 scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
divf4( mX, scalar ),
|
||||
divf4( mY, scalar ),
|
||||
divf4( mZ, scalar ),
|
||||
divf4( mW, scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( vec_float4 scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
negatef4( mX ),
|
||||
negatef4( mY ),
|
||||
negatef4( mZ ),
|
||||
negatef4( mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat0.getX(), quat1.getX() );
|
||||
result = spu_add( result, spu_mul( quat0.getY(), quat1.getY() ) );
|
||||
result = spu_add( result, spu_mul( quat0.getZ(), quat1.getZ() ) );
|
||||
result = spu_add( result, spu_mul( quat0.getW(), quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 norm( const Quat & quat )
|
||||
{
|
||||
vec_float4 result;
|
||||
result = spu_mul( quat.getX(), quat.getX() );
|
||||
result = spu_add( result, spu_mul( quat.getY(), quat.getY() ) );
|
||||
result = spu_add( result, spu_mul( quat.getZ(), quat.getZ() ) );
|
||||
result = spu_add( result, spu_mul( quat.getW(), quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline vec_float4 length( const Quat & quat )
|
||||
{
|
||||
return sqrtf4( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
vec_float4 lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = rsqrtf4( lenSqr );
|
||||
return Quat(
|
||||
spu_mul( quat.getX(), lenInv ),
|
||||
spu_mul( quat.getY(), lenInv ),
|
||||
spu_mul( quat.getZ(), lenInv ),
|
||||
spu_mul( quat.getW(), lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( s, spu_splats(0.0f), spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( spu_splats(0.0f), s, spu_splats(0.0f), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( vec_float4 radians )
|
||||
{
|
||||
vec_float4 s, c, angle;
|
||||
angle = spu_mul( radians, spu_splats(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
return Quat( spu_splats(0.0f), spu_splats(0.0f), s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mX ), spu_mul( mX, quat.mW ) ), spu_mul( mY, quat.mZ ) ), spu_mul( mZ, quat.mY ) ),
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mY ), spu_mul( mY, quat.mW ) ), spu_mul( mZ, quat.mX ) ), spu_mul( mX, quat.mZ ) ),
|
||||
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mZ ), spu_mul( mZ, quat.mW ) ), spu_mul( mX, quat.mY ) ), spu_mul( mY, quat.mX ) ),
|
||||
spu_sub( spu_sub( spu_sub( spu_mul( mW, quat.mW ), spu_mul( mX, quat.mX ) ), spu_mul( mY, quat.mY ) ), spu_mul( mZ, quat.mZ ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
vec_float4 tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = spu_sub( spu_add( spu_mul( quat.getW(), vec.getX() ), spu_mul( quat.getY(), vec.getZ() ) ), spu_mul( quat.getZ(), vec.getY() ) );
|
||||
tmpY = spu_sub( spu_add( spu_mul( quat.getW(), vec.getY() ), spu_mul( quat.getZ(), vec.getX() ) ), spu_mul( quat.getX(), vec.getZ() ) );
|
||||
tmpZ = spu_sub( spu_add( spu_mul( quat.getW(), vec.getZ() ), spu_mul( quat.getX(), vec.getY() ) ), spu_mul( quat.getY(), vec.getX() ) );
|
||||
tmpW = spu_add( spu_add( spu_mul( quat.getX(), vec.getX() ), spu_mul( quat.getY(), vec.getY() ) ), spu_mul( quat.getZ(), vec.getZ() ) );
|
||||
return Vector3(
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getX() ), spu_mul( tmpX, quat.getW() ) ), spu_mul( tmpY, quat.getZ() ) ), spu_mul( tmpZ, quat.getY() ) ),
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getY() ), spu_mul( tmpY, quat.getW() ) ), spu_mul( tmpZ, quat.getX() ) ), spu_mul( tmpX, quat.getZ() ) ),
|
||||
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getZ() ), spu_mul( tmpZ, quat.getW() ) ), spu_mul( tmpX, quat.getY() ) ), spu_mul( tmpY, quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
|
||||
{
|
||||
return Quat(
|
||||
spu_sel( quat0.getX(), quat1.getX(), select1 ),
|
||||
spu_sel( quat0.getY(), quat1.getY(), select1 ),
|
||||
spu_sel( quat0.getZ(), quat1.getZ(), select1 ),
|
||||
spu_sel( quat0.getW(), quat1.getW(), select1 )
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
Aos::Quat vec0, vec1, vec2, vec3;
|
||||
printf( "%s:\n", name );
|
||||
quat.get4Aos( vec0, vec1, vec2, vec3 );
|
||||
printf("slot 0:\n");
|
||||
print( vec0 );
|
||||
printf("slot 1:\n");
|
||||
print( vec1 );
|
||||
printf("slot 2:\n");
|
||||
print( vec2 );
|
||||
printf("slot 3:\n");
|
||||
print( vec3 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Soa
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
||||
/*
|
||||
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_VECIDX_AOS_H
|
||||
#define _VECTORMATH_VECIDX_AOS_H
|
||||
|
||||
#include <spu_intrinsics.h>
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VecIdx
|
||||
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
|
||||
// subscripting operator.
|
||||
//
|
||||
|
||||
class VecIdx
|
||||
{
|
||||
private:
|
||||
typedef vec_float4 vec_float4_t;
|
||||
vec_float4_t &ref __attribute__ ((aligned(16)));
|
||||
int i __attribute__ ((aligned(16)));
|
||||
public:
|
||||
inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; }
|
||||
inline operator float() const;
|
||||
inline float operator =( float scalar );
|
||||
inline float operator =( const VecIdx& scalar );
|
||||
inline float operator *=( float scalar );
|
||||
inline float operator /=( float scalar );
|
||||
inline float operator +=( float scalar );
|
||||
inline float operator -=( float scalar );
|
||||
};
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
/*
|
||||
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_VECIDX_AOS_H
|
||||
#define _VECTORMATH_VECIDX_AOS_H
|
||||
|
||||
#include <spu_intrinsics.h>
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VecIdx
|
||||
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
|
||||
// subscripting operator.
|
||||
//
|
||||
|
||||
class VecIdx
|
||||
{
|
||||
private:
|
||||
typedef vec_float4 vec_float4_t;
|
||||
vec_float4_t &ref __attribute__ ((aligned(16)));
|
||||
int i __attribute__ ((aligned(16)));
|
||||
public:
|
||||
inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; }
|
||||
inline operator float() const;
|
||||
inline float operator =( float scalar );
|
||||
inline float operator =( const VecIdx& scalar );
|
||||
inline float operator *=( float scalar );
|
||||
inline float operator /=( float scalar );
|
||||
inline float operator +=( float scalar );
|
||||
inline float operator -=( float scalar );
|
||||
};
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
135
Extras/vectormathlibrary/tests/Makefile
Normal file
135
Extras/vectormathlibrary/tests/Makefile
Normal 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
|
||||
109
Extras/vectormathlibrary/tests/clean.pl
Normal file
109
Extras/vectormathlibrary/tests/clean.pl
Normal 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;
|
||||
}
|
||||
95
Extras/vectormathlibrary/tests/compare.pl
Normal file
95
Extras/vectormathlibrary/tests/compare.pl
Normal 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +1,163 @@
|
||||
|
||||
///Testfile to test differences between vectormath and Bullet LinearMath
|
||||
|
||||
#ifdef __PPU__
|
||||
#include "include/vectormath/ppu/cpp/vectormath_aos.h"
|
||||
#elif defined __SPU__
|
||||
#include "include/vectormath/spu/cpp/vectormath_aos.h"
|
||||
#else
|
||||
#include "include/vectormath/SSE/cpp/vectormath_aos.h"
|
||||
//#include "include/vectormath/scalar/cpp/vectormath_aos.h"
|
||||
#endif
|
||||
|
||||
#include "../../src/LinearMath/btTransform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//Bullet, a btVector can be used for both points and vectors.
|
||||
//it is up to the user/developer to use the right multiplication: btTransform for points, and btQuaternion or btMatrix3x3 for vectors.
|
||||
void BulletTest()
|
||||
{
|
||||
|
||||
printf("Bullet Linearmath\n");
|
||||
|
||||
btTransform tr;
|
||||
tr.setIdentity();
|
||||
|
||||
tr.setOrigin(btVector3(10,0,0));
|
||||
//initialization
|
||||
btVector3 pointA(0,0,0);
|
||||
btVector3 pointB,pointC,pointD,pointE;
|
||||
//assignment
|
||||
pointB = pointA;
|
||||
//in-place initialization
|
||||
pointB.setValue(1,2,3);
|
||||
//transform over tr
|
||||
pointB = tr * pointA;
|
||||
printf("pointB = tr * pointA = (%f,%f,%f)\n",pointB.getX(),pointB.getY(),pointB.getZ());
|
||||
//transform over tr
|
||||
pointE = tr(pointA);
|
||||
//inverse transform
|
||||
pointC = tr.inverse() * pointA;
|
||||
printf("pointC = tr.inverse() * pointA = (%f,%f,%f)\n",pointC.getX(),pointC.getY(),pointC.getZ());
|
||||
//inverse transform
|
||||
pointD = tr.invXform( pointA );
|
||||
btScalar x;
|
||||
//dot product
|
||||
x = pointD.dot(pointE);
|
||||
//square length
|
||||
x = pointD.length2();
|
||||
//length
|
||||
x = pointD.length();
|
||||
|
||||
const btVector3& constPointD = pointD;
|
||||
|
||||
//get a normalized vector from constPointD, without changing constPointD
|
||||
btVector3 norm = constPointD.normalized();
|
||||
|
||||
//in-place normalize pointD
|
||||
pointD.normalize();
|
||||
|
||||
//quaternions & matrices
|
||||
btQuaternion quat(0,0,0,1);
|
||||
btQuaternion quat1(btVector3(0,1,0),90.f * SIMD_RADS_PER_DEG);
|
||||
btMatrix3x3 mat0(quat1);
|
||||
btMatrix3x3 mat1 = mat0.inverse();
|
||||
btMatrix3x3 mat2 = mat0.transpose();
|
||||
btTransform tr1(mat2,btVector3(0,10,0));
|
||||
btTransform tr2 =tr1.inverse();
|
||||
btVector3 pt0(1,1,1);
|
||||
btVector3 pt1 = tr2 * pt0;
|
||||
|
||||
printf("btVector3 pt1 = tr2 * pt0 = (%f,%f,%f)\n",pt1.getX(),pt1.getY(),pt1.getZ());
|
||||
|
||||
|
||||
btVector3 pt2 = tr2.getBasis() * pt0;
|
||||
btVector3 pt3 = pt0 * tr2.getBasis();
|
||||
btVector3 pt4 = tr2.getBasis().inverse() * pt0;
|
||||
btTransform tr3 = tr2.inverseTimes(tr2);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//vectormath makes a difference between point and vector.
|
||||
void VectormathTest()
|
||||
{
|
||||
|
||||
printf("Vectormath\n");
|
||||
|
||||
Vectormath::Aos::Transform3 tr;
|
||||
tr = Vectormath::Aos::Transform3::identity();
|
||||
|
||||
tr.setTranslation(Vectormath::Aos::Vector3(10,0,0));
|
||||
//initialization
|
||||
Vectormath::Aos::Point3 pointA(0,0,0);
|
||||
Vectormath::Aos::Point3 pointB,pointC,pointE;
|
||||
Vectormath::Aos::Vector3 pointD;
|
||||
//assignment
|
||||
pointB = pointA;
|
||||
//in-place initialization
|
||||
pointB = Vectormath::Aos::Point3(1,2,3); //or
|
||||
pointB.setElem(0,1); //or
|
||||
pointB.setX(1);
|
||||
|
||||
//transform over tr
|
||||
pointB = tr * pointA;
|
||||
|
||||
printf("pointB = tr * pointA = (%f,%f,%f)\n",(float)pointB.getX(),(float)pointB.getY(),(float)pointB.getZ());
|
||||
//transform over tr
|
||||
//pointE = tr(pointA);
|
||||
//inverse transform
|
||||
pointC = Vectormath::Aos::inverse(tr) * pointA;
|
||||
printf("Vectormath::Aos::inverse(tr) * pointA = (%f,%f,%f)\n",(float)pointC.getX(),(float)pointC.getY(),(float)pointC.getZ());
|
||||
|
||||
|
||||
|
||||
btScalar x;
|
||||
//dot product
|
||||
x = Vectormath::Aos::dot(Vectormath::Aos::Vector3(pointD),Vectormath::Aos::Vector3(pointE));
|
||||
//square length
|
||||
x = Vectormath::Aos::lengthSqr(Vectormath::Aos::Vector3(pointD));
|
||||
//length
|
||||
x = Vectormath::Aos::length(Vectormath::Aos::Vector3(pointD));
|
||||
|
||||
const Vectormath::Aos::Vector3& constPointD = (Vectormath::Aos::Vector3&)pointD;
|
||||
|
||||
//get a normalized vector from constPointD, without changing constPointD
|
||||
Vectormath::Aos::Vector3 norm = Vectormath::Aos::normalize(constPointD);
|
||||
|
||||
//in-place normalize pointD
|
||||
pointD = Vectormath::Aos::normalize(Vectormath::Aos::Vector3(pointD));
|
||||
|
||||
//quaternions & matrices
|
||||
Vectormath::Aos::Quat quat(0,0,0,1);
|
||||
Vectormath::Aos::Quat quat1;
|
||||
quat1 = Vectormath::Aos::Quat::rotationY(90.f * SIMD_RADS_PER_DEG);
|
||||
|
||||
Vectormath::Aos::Matrix3 mat0(quat1);
|
||||
|
||||
Vectormath::Aos::Matrix3 mat1 = Vectormath::Aos::inverse(mat0);
|
||||
Vectormath::Aos::Matrix3 mat2 = Vectormath::Aos::transpose(mat0);
|
||||
Vectormath::Aos::Transform3 tr1(mat2,Vectormath::Aos::Vector3(0,10,0));
|
||||
Vectormath::Aos::Transform3 tr2 = Vectormath::Aos::inverse(tr1);
|
||||
Vectormath::Aos::Point3 pt0(1,1,1);
|
||||
Vectormath::Aos::Point3 pt1 = tr2 * pt0;
|
||||
printf("Vectormath::Aos::Vector3 pt1 = tr2 * pt0; = (%f,%f,%f)\n",(float)pt1.getX(),(float)pt1.getY(),(float)pt1.getZ());
|
||||
|
||||
Vectormath::Aos::Vector3 pt2 = tr2.getUpper3x3() * Vectormath::Aos::Vector3(pt0);
|
||||
//Vectormath::Aos::Vector3 pt3 = pt0 * tr2.getUpper3x3();
|
||||
Vectormath::Aos::Vector3 pt3 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0);
|
||||
Vectormath::Aos::Vector3 pt4 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0);
|
||||
Vectormath::Aos::Transform3 tr3 = Vectormath::Aos::inverse(tr2) * tr2;
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
BulletTest();
|
||||
|
||||
VectormathTest();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///Testfile to test differences between vectormath and Bullet LinearMath
|
||||
|
||||
#ifdef __PPU__
|
||||
#include "include/vectormath/ppu/cpp/vectormath_aos.h"
|
||||
#elif defined __SPU__
|
||||
#include "include/vectormath/spu/cpp/vectormath_aos.h"
|
||||
#else
|
||||
#include "include/vectormath/SSE/cpp/vectormath_aos.h"
|
||||
//#include "include/vectormath/scalar/cpp/vectormath_aos.h"
|
||||
#endif
|
||||
|
||||
#include "../../src/LinearMath/btTransform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//Bullet, a btVector can be used for both points and vectors.
|
||||
//it is up to the user/developer to use the right multiplication: btTransform for points, and btQuaternion or btMatrix3x3 for vectors.
|
||||
void BulletTest()
|
||||
{
|
||||
|
||||
printf("Bullet Linearmath\n");
|
||||
|
||||
btTransform tr;
|
||||
tr.setIdentity();
|
||||
|
||||
tr.setOrigin(btVector3(10,0,0));
|
||||
//initialization
|
||||
btVector3 pointA(0,0,0);
|
||||
btVector3 pointB,pointC,pointD,pointE;
|
||||
//assignment
|
||||
pointB = pointA;
|
||||
//in-place initialization
|
||||
pointB.setValue(1,2,3);
|
||||
//transform over tr
|
||||
pointB = tr * pointA;
|
||||
printf("pointB = tr * pointA = (%f,%f,%f)\n",pointB.getX(),pointB.getY(),pointB.getZ());
|
||||
//transform over tr
|
||||
pointE = tr(pointA);
|
||||
//inverse transform
|
||||
pointC = tr.inverse() * pointA;
|
||||
printf("pointC = tr.inverse() * pointA = (%f,%f,%f)\n",pointC.getX(),pointC.getY(),pointC.getZ());
|
||||
//inverse transform
|
||||
pointD = tr.invXform( pointA );
|
||||
btScalar x;
|
||||
//dot product
|
||||
x = pointD.dot(pointE);
|
||||
//square length
|
||||
x = pointD.length2();
|
||||
//length
|
||||
x = pointD.length();
|
||||
|
||||
const btVector3& constPointD = pointD;
|
||||
|
||||
//get a normalized vector from constPointD, without changing constPointD
|
||||
btVector3 norm = constPointD.normalized();
|
||||
|
||||
//in-place normalize pointD
|
||||
pointD.normalize();
|
||||
|
||||
//quaternions & matrices
|
||||
btQuaternion quat(0,0,0,1);
|
||||
btQuaternion quat1(btVector3(0,1,0),90.f * SIMD_RADS_PER_DEG);
|
||||
btMatrix3x3 mat0(quat1);
|
||||
btMatrix3x3 mat1 = mat0.inverse();
|
||||
btMatrix3x3 mat2 = mat0.transpose();
|
||||
btTransform tr1(mat2,btVector3(0,10,0));
|
||||
btTransform tr2 =tr1.inverse();
|
||||
btVector3 pt0(1,1,1);
|
||||
btVector3 pt1 = tr2 * pt0;
|
||||
|
||||
printf("btVector3 pt1 = tr2 * pt0 = (%f,%f,%f)\n",pt1.getX(),pt1.getY(),pt1.getZ());
|
||||
|
||||
|
||||
btVector3 pt2 = tr2.getBasis() * pt0;
|
||||
btVector3 pt3 = pt0 * tr2.getBasis();
|
||||
btVector3 pt4 = tr2.getBasis().inverse() * pt0;
|
||||
btTransform tr3 = tr2.inverseTimes(tr2);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//vectormath makes a difference between point and vector.
|
||||
void VectormathTest()
|
||||
{
|
||||
|
||||
printf("Vectormath\n");
|
||||
|
||||
Vectormath::Aos::Transform3 tr;
|
||||
tr = Vectormath::Aos::Transform3::identity();
|
||||
|
||||
tr.setTranslation(Vectormath::Aos::Vector3(10,0,0));
|
||||
//initialization
|
||||
Vectormath::Aos::Point3 pointA(0,0,0);
|
||||
Vectormath::Aos::Point3 pointB,pointC,pointE;
|
||||
Vectormath::Aos::Vector3 pointD;
|
||||
//assignment
|
||||
pointB = pointA;
|
||||
//in-place initialization
|
||||
pointB = Vectormath::Aos::Point3(1,2,3); //or
|
||||
pointB.setElem(0,1); //or
|
||||
pointB.setX(1);
|
||||
|
||||
//transform over tr
|
||||
pointB = tr * pointA;
|
||||
|
||||
printf("pointB = tr * pointA = (%f,%f,%f)\n",(float)pointB.getX(),(float)pointB.getY(),(float)pointB.getZ());
|
||||
//transform over tr
|
||||
//pointE = tr(pointA);
|
||||
//inverse transform
|
||||
pointC = Vectormath::Aos::inverse(tr) * pointA;
|
||||
printf("Vectormath::Aos::inverse(tr) * pointA = (%f,%f,%f)\n",(float)pointC.getX(),(float)pointC.getY(),(float)pointC.getZ());
|
||||
|
||||
|
||||
|
||||
btScalar x;
|
||||
//dot product
|
||||
x = Vectormath::Aos::dot(Vectormath::Aos::Vector3(pointD),Vectormath::Aos::Vector3(pointE));
|
||||
//square length
|
||||
x = Vectormath::Aos::lengthSqr(Vectormath::Aos::Vector3(pointD));
|
||||
//length
|
||||
x = Vectormath::Aos::length(Vectormath::Aos::Vector3(pointD));
|
||||
|
||||
const Vectormath::Aos::Vector3& constPointD = (Vectormath::Aos::Vector3&)pointD;
|
||||
|
||||
//get a normalized vector from constPointD, without changing constPointD
|
||||
Vectormath::Aos::Vector3 norm = Vectormath::Aos::normalize(constPointD);
|
||||
|
||||
//in-place normalize pointD
|
||||
pointD = Vectormath::Aos::normalize(Vectormath::Aos::Vector3(pointD));
|
||||
|
||||
//quaternions & matrices
|
||||
Vectormath::Aos::Quat quat(0,0,0,1);
|
||||
Vectormath::Aos::Quat quat1;
|
||||
quat1 = Vectormath::Aos::Quat::rotationY(90.f * SIMD_RADS_PER_DEG);
|
||||
|
||||
Vectormath::Aos::Matrix3 mat0(quat1);
|
||||
|
||||
Vectormath::Aos::Matrix3 mat1 = Vectormath::Aos::inverse(mat0);
|
||||
Vectormath::Aos::Matrix3 mat2 = Vectormath::Aos::transpose(mat0);
|
||||
Vectormath::Aos::Transform3 tr1(mat2,Vectormath::Aos::Vector3(0,10,0));
|
||||
Vectormath::Aos::Transform3 tr2 = Vectormath::Aos::inverse(tr1);
|
||||
Vectormath::Aos::Point3 pt0(1,1,1);
|
||||
Vectormath::Aos::Point3 pt1 = tr2 * pt0;
|
||||
printf("Vectormath::Aos::Vector3 pt1 = tr2 * pt0; = (%f,%f,%f)\n",(float)pt1.getX(),(float)pt1.getY(),(float)pt1.getZ());
|
||||
|
||||
Vectormath::Aos::Vector3 pt2 = tr2.getUpper3x3() * Vectormath::Aos::Vector3(pt0);
|
||||
//Vectormath::Aos::Vector3 pt3 = pt0 * tr2.getUpper3x3();
|
||||
Vectormath::Aos::Vector3 pt3 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0);
|
||||
Vectormath::Aos::Vector3 pt4 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0);
|
||||
Vectormath::Aos::Transform3 tr3 = Vectormath::Aos::inverse(tr2) * tr2;
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
BulletTest();
|
||||
|
||||
VectormathTest();
|
||||
|
||||
return 0;
|
||||
}
|
||||
346
Extras/vectormathlibrary/tests/test.h
Normal file
346
Extras/vectormathlibrary/tests/test.h
Normal 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
|
||||
1153
Extras/vectormathlibrary/tests/test1_aos_c.c
Normal file
1153
Extras/vectormathlibrary/tests/test1_aos_c.c
Normal file
File diff suppressed because it is too large
Load Diff
1102
Extras/vectormathlibrary/tests/test1_aos_cpp.cpp
Normal file
1102
Extras/vectormathlibrary/tests/test1_aos_cpp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
680
Extras/vectormathlibrary/tests/test1_reference.txt
Normal file
680
Extras/vectormathlibrary/tests/test1_reference.txt
Normal 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__
|
||||
1006
Extras/vectormathlibrary/tests/test1_soa_c.c
Normal file
1006
Extras/vectormathlibrary/tests/test1_soa_c.c
Normal file
File diff suppressed because it is too large
Load Diff
931
Extras/vectormathlibrary/tests/test1_soa_cpp.cpp
Normal file
931
Extras/vectormathlibrary/tests/test1_soa_cpp.cpp
Normal 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;
|
||||
}
|
||||
852
Extras/vectormathlibrary/tests/test2_aos_c.c
Normal file
852
Extras/vectormathlibrary/tests/test2_aos_c.c
Normal 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;
|
||||
}
|
||||
784
Extras/vectormathlibrary/tests/test2_aos_cpp.cpp
Normal file
784
Extras/vectormathlibrary/tests/test2_aos_cpp.cpp
Normal 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;
|
||||
}
|
||||
1190
Extras/vectormathlibrary/tests/test2_reference.txt
Normal file
1190
Extras/vectormathlibrary/tests/test2_reference.txt
Normal file
File diff suppressed because it is too large
Load Diff
760
Extras/vectormathlibrary/tests/test2_soa_c.c
Normal file
760
Extras/vectormathlibrary/tests/test2_soa_c.c
Normal 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;
|
||||
}
|
||||
718
Extras/vectormathlibrary/tests/test2_soa_cpp.cpp
Normal file
718
Extras/vectormathlibrary/tests/test2_soa_cpp.cpp
Normal 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;
|
||||
}
|
||||
524
Extras/vectormathlibrary/tests/test3_aos_c.c
Normal file
524
Extras/vectormathlibrary/tests/test3_aos_c.c
Normal 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;
|
||||
}
|
||||
476
Extras/vectormathlibrary/tests/test3_aos_cpp.cpp
Normal file
476
Extras/vectormathlibrary/tests/test3_aos_cpp.cpp
Normal 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;
|
||||
}
|
||||
392
Extras/vectormathlibrary/tests/test3_reference.txt
Normal file
392
Extras/vectormathlibrary/tests/test3_reference.txt
Normal 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__
|
||||
433
Extras/vectormathlibrary/tests/test3_soa_c.c
Normal file
433
Extras/vectormathlibrary/tests/test3_soa_c.c
Normal 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;
|
||||
}
|
||||
410
Extras/vectormathlibrary/tests/test3_soa_cpp.cpp
Normal file
410
Extras/vectormathlibrary/tests/test3_soa_cpp.cpp
Normal 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;
|
||||
}
|
||||
567
Extras/vectormathlibrary/tests/test4_aos_c.c
Normal file
567
Extras/vectormathlibrary/tests/test4_aos_c.c
Normal 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;
|
||||
}
|
||||
492
Extras/vectormathlibrary/tests/test4_aos_cpp.cpp
Normal file
492
Extras/vectormathlibrary/tests/test4_aos_cpp.cpp
Normal 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;
|
||||
}
|
||||
524
Extras/vectormathlibrary/tests/test4_reference.txt
Normal file
524
Extras/vectormathlibrary/tests/test4_reference.txt
Normal 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__
|
||||
474
Extras/vectormathlibrary/tests/test4_soa_c.c
Normal file
474
Extras/vectormathlibrary/tests/test4_soa_c.c
Normal 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;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user