Code Monkey home page Code Monkey logo

kazmath's Introduction

Kazmath

Kazmath is a simple 3D maths library written in C. It was initially coded for use in my book, Beginning OpenGL Game Programming - Second edition, but rapidly gained a life of its own. Kazmath is now used by many different projects, and apparently is used in 25% of the worlds mobile games (yeah, I don't believe it either - but it's used in Cocos2d-x).

If you are using Kazmath in a project, I'd be happy to hear about it. Find me on Twitter as @kazade.

Compiling

Compiling is simple using CMake, on Linux:

mkdir build
cd build
cmake ..
make
sudo make install

On other platforms use CMake to generate an appropriate project file.

If you want to build shared libraries you should pass -DBUILD_SHARED_LIBS=YES to the cmake command

Contributing

There are many improvements that could be made to kazmath, including:

  • More tests
  • More optimizations
  • More functions, and primitives
  • More bindings (e.g. Python)

All contributions are welcome. Just send me a pull request on GitHub and I'll review and probably merge!

Donations

If you like what I do, I'm happy to receive donations in DOGE to this address: D6uwEfChxWmWjFGs4jT8VRtabYaza5oAGx :)

Thank you!

kazmath's People

Contributors

anibali avatar bzar avatar carloscm avatar chaubold avatar chriscamacho avatar cloudef avatar danoli3 avatar davidaciko avatar dgivone avatar dhontecillas avatar hgs3 avatar jj avatar johang88 avatar kazade avatar mazeto avatar nmichaels avatar prideout avatar rocaltair avatar starbugs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kazmath's Issues

Cannot build on Windows using VC++ compiler.

Currently, trying to build on Windows using the Visual C++ compiler bundled with Visual Studio causes the following error (plus a host of warnings concerning uninitialized variables):

Cannot open include file: 'pthread.h': No such file or directory : matrix.c

create python wrapper

using boost::python, but make building it optional to keep the dependencies for the default build small

Bug in kmSegment2WithSegmentIntersection

In kmSegment2WithSegmentIntersection in ray2.c:

    if( kmLine2WithLineIntersection( &(segmentA->start), &(segmentA->dir), 
                                    &(segmentB->start), &(segmentB->start),
                                    &ua, &ub, &pt ) && 
        (0.0 <= ua) && (ua <= 1.0) && (0.0 <= ub) && (ub <= 1.0)) {
        intersection->x = pt.x;
        intersection->y = pt.y;
        return KM_TRUE;    
    }

Should be

    if( kmLine2WithLineIntersection( &(segmentA->start), &(segmentA->dir), 
                                    &(segmentB->start), &(segmentB->dir),
                                    &ua, &ub, &pt ) && 
        (0.0 <= ua) && (ua <= 1.0) && (0.0 <= ub) && (ub <= 1.0)) {
        intersection->x = pt.x;
        intersection->y = pt.y;
        return KM_TRUE;    
    }

Note the duplicated start in segmentB->start. The second one should be segmentB->dir
Not sure this is better than a PR?

Cheers.

What is ub variable used for?

I wanted to know what is the following variable used for.

File ray2.c on line 31:

  • 31: kmScalar ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom;

It is declared and initialized but never used.

on lines 33,34

  • 33: kmScalar x = x1 + ua * (x2 - x1);
  • 34: kmScalar y = y1 + ua * (y2 - y1);

ua variable is used two times.

Was the ua variable on line 34 meant to be ub?

error: ‘isnan’ was not declared in this scope

Hi.

Im getting an error while building the library per instructions.

sbr@hiltrud ~/Code/kazmath/build $ make
Scanning dependencies of target kazmath
[  5%] Building C object kazmath/CMakeFiles/kazmath.dir/mat4.c.o
[ 11%] Building C object kazmath/CMakeFiles/kazmath.dir/mat3.c.o
[ 16%] Building C object kazmath/CMakeFiles/kazmath.dir/plane.c.o
[ 22%] Building C object kazmath/CMakeFiles/kazmath.dir/vec4.c.o
[ 27%] Building C object kazmath/CMakeFiles/kazmath.dir/quaternion.c.o
[ 33%] Building C object kazmath/CMakeFiles/kazmath.dir/vec2.c.o
[ 38%] Building C object kazmath/CMakeFiles/kazmath.dir/vec3.c.o
[ 44%] Building C object kazmath/CMakeFiles/kazmath.dir/utility.c.o
[ 50%] Building C object kazmath/CMakeFiles/kazmath.dir/aabb2.c.o
[ 55%] Building C object kazmath/CMakeFiles/kazmath.dir/aabb3.c.o
[ 61%] Building C object kazmath/CMakeFiles/kazmath.dir/ray2.c.o
[ 66%] Building C object kazmath/CMakeFiles/kazmath.dir/ray3.c.o
[ 72%] Building C object kazmath/CMakeFiles/kazmath.dir/GL/mat4stack.c.o
[ 77%] Building C object kazmath/CMakeFiles/kazmath.dir/GL/matrix.c.o
[ 83%] Linking C static library libkazmath.a
[ 83%] Built target kazmath
[ 88%] Generating ../../tests/main.cpp
Scanning dependencies of target kazmath_tests
[ 94%] Building CXX object tests/CMakeFiles/kazmath_tests.dir/main.cpp.o
In file included from /home/sbr/Code/kazmath/tests/main.cpp:5:0:
/home/sbr/Code/kazmath/tests/test_quaternion.h: In member function ‘void TestQuaternion::test_quaternion_slerp_edge_case()’:
/home/sbr/Code/kazmath/tests/test_quaternion.h:33:36: error: ‘isnan’ was not declared in this scope
         assert_true(!isnan(result.x));
                                    ^
/home/sbr/Code/kazmath/tests/kaztest/kaztest.h:15:43: note: in definition of macro ‘assert_true’
 #define assert_true(actual) _assert_true((actual), __FILE__, __LINE__)
                                           ^
/home/sbr/Code/kazmath/tests/test_quaternion.h:33:36: note: suggested alternative:
         assert_true(!isnan(result.x));
                                    ^
/home/sbr/Code/kazmath/tests/kaztest/kaztest.h:15:43: note: in definition of macro ‘assert_true’
 #define assert_true(actual) _assert_true((actual), __FILE__, __LINE__)
                                           ^
In file included from /usr/include/c++/5/random:38:0,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /home/sbr/Code/kazmath/tests/kaztest/kaztest.h:9,
                 from /home/sbr/Code/kazmath/tests/main.cpp:5:
/usr/include/c++/5/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^
tests/CMakeFiles/kazmath_tests.dir/build.make:76: recipe for target 'tests/CMakeFiles/kazmath_tests.dir/main.cpp.o' failed
make[2]: *** [tests/CMakeFiles/kazmath_tests.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'tests/CMakeFiles/kazmath_tests.dir/all' failed
make[1]: *** [tests/CMakeFiles/kazmath_tests.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

Im using gcc 5.4.0. on Ubuntu.

Kazmath's GL stack doesn't allow for multiple GL contexts/multithreading

Unfortunately, the current GL stack implementation crashes when calling it from different threads using multiple OpenGL contexts. As I required this specific functionality, I forked kazmath and implemented a TLS based context switch for the stack module (see http://github.com/starbugs/kazmath).

With my modifications, the only thing people have to do when they switch GL contexts is to call kmGLSetCurrentContext(void *) providing a reference to some external context representation that is constant for the lifecycle of a given real GL context. kazmath will then provide a stack for each context automatically (without any changes to the stack interface). My modifications merely require linking to libpthread.

Some background info: I am authoring a GL-based UI framework for iOS/Mac OS X which uses kazmath for most of the math and vector stuff (http://github.com/starbugs/icedcoffee). My modifications have been tested by a very small group of people currently experimenting with my framework -- no issues so far.

Anyway, I thought I just give you a ping and ask whether you're interested in pulling these changes? Maybe they are beneficial to others...

Big thanks for the great library!

Tobias

kazmath fails on test_mat4_and_quaternion_consistency

I am trying to use Kazmath for my engine, but I am having issues with incorrect lookAt, so I launched the test and I got this :

./kazmath_tests

1.000000 0.000000 0.000000

1.000000 0.000000 0.000000
/home/gpinchon/Bureau/projects/OpenGL/kazmath/tests/test_mat4.cpp:66: error: Failure in test_mat4_and_quaternion_consistency: kmMat4AreEqual(&tmp, &mat)
FAILURE: 1 out of 37 tests failed (1 failures).
Test time: 0.00 seconds.

pthread_getspecific return null

Hi Kazade,
Thanks for your greate job to create this useful math library.
I use it both in my ios and android project, it works well in my ios project, however in my android project, the function "pthread_getspecific(current_context_key)" always return null, it was called in a sub thread named GLThread, as below img:
2018-06-15 4 51 43
Could you please tell me why this case and how to solve it?
Thanks.

Minor CMake issue?

I'm getting an error in CMake while building. It says it requires "language dialect C89" but that CMake doesn't know the compile flags for it.

As far as I can tell CMake only supports C90, C99 and C11 for CMAKE_C_STANDARD.Is it ok if I change it to C99? C89 and 90 apparently don't support single line '//' comments and I saw a whole bunch of those in the project.

While I'm at it, I wanted to add an option to build shared libs for CMake-gui and a pkg-config file. Any interest?

Cannot build on OSX 10.11.6

Steps to reproduce:

git clone https://github.com/Kazade/kazmath.git
cd kazmath
mkdir build
cd build
cmake ..
make

produces:

/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:53:34: warning: variadic
      templates are a C++11 extension [-Wc++11-extensions]
    template<typename T, typename... Args>
                                 ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:60:34: warning: variadic
      templates are a C++11 extension [-Wc++11-extensions]
    template<typename T, typename... Args>
                                 ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:96:5: error: exception
      specification of overriding function is more lax than base version
    ~AssertionError() noexcept (true) {
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdexcept:76:13: note:
      overridden virtual function is here
    virtual ~logic_error() _NOEXCEPT;
            ^
In file included from /Users/jamiltron/opt/kazmath/tests/main.cpp:5:
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:96:22: error: expected ';'
      at end of declaration list
    ~AssertionError() noexcept (true) {
                     ^
                     ;
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:85:9: error: member
      initializer 'file' does not name a non-static data member or base class
        file(""),
        ^~~~~~~~
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:91:9: error: member
      initializer 'file' does not name a non-static data member or base class
        file(file_and_line.first),
        ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:121:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:129:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:137:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:146:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:154:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:162:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:171:13: warning: 'auto'
      type specifier is a C++11 extension [-Wc++11-extensions]
            auto file_and_line = std::make_pair(file, line);
            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:293:41: error: a space is
      required between consecutive right angle brackets (use '> >')
    std::vector<std::shared_ptr<TestCase>> instances_;
                                        ^~
                                        > >
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:189:29: warning:
      range-based for loop is a C++11 extension [-Wc++11-extensions]
        for(std::string name: names) {
                            ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:193:22: warning:
      range-based for loop is a C++11 extension [-Wc++11-extensions]
        for(U& method: methods) {
                     ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:194:47: error: no member
      named 'bind' in namespace 'std'; did you mean 'find'?
            std::function<void()> func = std::bind(method, dynamic_cast<...
                                         ~~~~~^~~~
                                              find
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:862:1: note:
      'find' declared here
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
^
In file included from /Users/jamiltron/opt/kazmath/tests/main.cpp:5:
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:195:30: error: expected
      expression
            tests_.push_back([=]() {
                             ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:209:9: warning: 'auto' type
      specifier is a C++11 extension [-Wc++11-extensions]
        auto new_tests = tests_;
        ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:210:9: warning: 'auto' type
      specifier is a C++11 extension [-Wc++11-extensions]
        auto new_names = names_;
        ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:226:40: warning:
      range-based for loop is a C++11 extension [-Wc++11-extensions]
        for(std::function<void ()> test: new_tests) {
                                       ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:243:23: error: no member
      named 'file' in 'AssertionError'
                if(!e.file.empty()) {
                    ~ ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:244:50: error: no member
      named 'file' in 'AssertionError'
                    std::cout << "        " << e.file << ":" << e.line <...
                                               ~ ^
/Users/jamiltron/opt/kazmath/tests/kaztest/kaztest.h:246:41: error: no member
      named 'file' in 'AssertionError'
                    std::ifstream ifs(e.file);
                                      ~ ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:27:43: error: expected expression
        std::vector<void (TestAABB::*)()>({&TestAABB::test_aabb_expand_t...
                                          ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:28:9: error: expected expression
        {"TestAABB::test_aabb_expand_to_contain", "TestAABB::test_aabb_c...
        ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:32:43: error: expected expression
        std::vector<void (TestMat3::*)()>({&TestMat3::test_mat3_inverse...
                                          ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:33:9: error: expected expression
        {"TestMat3::test_mat3_inverse", "TestMat3::test_mat3_transpose"...
        ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:37:43: error: expected expression
        std::vector<void (TestMat4::*)()>({&TestMat4::test_mat4_inverse...
                                          ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:38:9: error: expected expression
        {"TestMat4::test_mat4_inverse", "TestMat4::test_mat4_and_quatern...
        ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:42:44: error: expected expression
        std::vector<void (TestPlane::*)()>({&TestPlane::test_plane_extra...
                                           ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:43:9: error: expected expression
        {"TestPlane::test_plane_extraction_from_matrix", "TestPlane::tes...
        ^
/Users/jamiltron/opt/kazmath/tests/main.cpp:47:49: error: expected expression
        std::vector<void (TestQuaternion::*)()>({&TestQuaternion::test_q...
                                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
14 warnings and 20 errors generated.
make[2]: *** [tests/CMakeFiles/kazmath_tests.dir/main.cpp.o] Error 1
make[1]: *** [tests/CMakeFiles/kazmath_tests.dir/all] Error 2
make: *** [all] Error 2

lua-binding for kazmath

hi~ @Kazade
I forked this
lua-binding

so far so good.

  • add all functions for kazmath/.h (except kazmath/GL/.h)
  • lkazmath.km* for all functions
  • use lkazmath._New or lkazmath._NewWithArray or lkazmath.*NewWithTbl to create a object (struct in C)
  • method ToArray, ToTbl for vec_, mat_
  • OOP support (without prefix km${StructName}), for example
mat3 = lkazmath.kmMat3New()
mat3:ToArray()

or you can use

lkazmath.kmMat3ToArray(mat3)
  • alter args(such as kmScalar *out are removed from function params), see lua__kmMat4RotationToAxisAngle, lua__kmLine2WithLineIntersection

Collision/response related functions

I'm probably going to contribute some collision/response related functions to kazmath somewhere in near future, and introduce new types such as kmOBB, kmEllipse, kmTriangle, ...

You can see video of the math in action here:
http://www.youtube.com/watch?v=HYW2lI3alG0

You can see the current code that is still unfinished and some math is broken here (at top of file everything prefixed with km):
https://github.com/Cloudef/colhck/blob/master/test/coltest.c

Though, I have question regarding kmAABBExtent, will this kind of type be pulled in or should the original kmAABB be replaced?

The reason for introducing kmAABBExtent is reduced memory usage.

Building - Java-related issues

First of all - I don't need Java bindings, is there a way to disable building it? I've looked through cmake files and haven't noticed any related flags.

Anyway, build fails for me:

  1. I make a build dir for out-of-source building, cd to it and run cmake .. and make
[ 44%] Building C object kazmath/CMakeFiles/kazmath.dir/GL/matrix.c.o
Linking C shared library libkazmath.so
[ 44%] Built target kazmath
[ 48%] Generating kazmath/jkazmath.class
[ 51%] Generating jni/kazmath_jkazmath.h
error: cannot access kazmath.jkazmath
class file for kazmath.jkazmath not found
javadoc: error - Class kazmath.jkazmath not found.
Error: No classes were specified on the command line.  Try -help.
make[2]: *** [java/jni/kazmath_jkazmath.h] Error 15
make[1]: *** [java/CMakeFiles/Jkazmath.dir/all] Error 2
make: *** [all] Error 2
ERROR  Last command returned non-zero exit status 2, it's error report should be above
  1. Seems like there may be a problem with the paths. Ok, I try again but run cmake . in source root dir (clean checkout).
[ 44%] Building C object kazmath/CMakeFiles/kazmath.dir/GL/matrix.c.o
Linking C shared library libkazmath.so
[ 44%] Built target kazmath
[ 48%] Generating kazmath/jkazmath.class
[ 51%] Generating jni/kazmath_jkazmath.h
Scanning dependencies of target Jkazmath
[ 55%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/mat4.c.o
[ 58%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/vec2.c.o
[ 62%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/ray2.c.o
[ 65%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/utility.c.o
[ 68%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/mat3.c.o
[ 72%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/plane.c.o
[ 75%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/aabb.c.o
[ 79%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/ray3.c.o
[ 82%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/vec4.c.o
[ 86%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/GL/matrix.c.o
[ 89%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/GL/mat4stack.c.o
[ 93%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/quaternion.c.o
[ 96%] Building C object java/CMakeFiles/Jkazmath.dir/__/kazmath/vec3.c.o
[100%] Building C object java/CMakeFiles/Jkazmath.dir/jni/kazmath.c.o
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmQuaternionConjugate’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:214:5: warning: implicit declaration of function ‘kmQuaternionConjugate’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmQuaternionNormalize’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:306:19: warning: unused variable ‘i’ [-Wunused-variable]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:305:19: warning: unused variable ‘o’ [-Wunused-variable]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmQuaternionRotationAxis’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:316:5: warning: implicit declaration of function ‘kmQuaternionRotationAxis’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmQuaternionRotationYawPitchRoll’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:335:5: warning: implicit declaration of function ‘kmQuaternionRotationYawPitchRoll’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmPlaneFromPointNormal’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:449:5: warning: implicit declaration of function ‘kmPlaneFromPointNormal’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmMat3Inverse’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:566:5: error: incompatible type for argument 2 of ‘kmMat3Inverse’
/home/f/proj/game_new/build/dev/kazmath/kazmath/mat3.h:50:9: note: expected ‘const struct kmMat3 *’ but argument is of type ‘jfloat’
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:566:5: error: too many arguments to function ‘kmMat3Inverse’
/home/f/proj/game_new/build/dev/kazmath/kazmath/mat3.h:50:9: note: declared here
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmMat4RotationPitchYawRoll’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:1091:5: warning: implicit declaration of function ‘kmMat4RotationPitchYawRoll’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmMat4GetForwardVec3’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:1143:5: warning: implicit declaration of function ‘kmMat4GetForwardVec3’ [-Wimplicit-function-declaration]
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c: In function ‘Java_kazmath_jkazmath_kmVec4TransformArray’:
/home/f/proj/game_new/build/dev/kazmath/java/jni/kazmath.c:129:1: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [java/CMakeFiles/Jkazmath.dir/jni/kazmath.c.o] Error 1
make[1]: *** [java/CMakeFiles/Jkazmath.dir/all] Error 2
make: *** [all] Error 2
ERROR  Last command returned non-zero exit status 2, it's error report should be above

Environment is Ubuntu 12.04.3,

$ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2)

Kazmath is latest from master (1f3ce5a)

some parameters missing const

to be honest not sure if this is even an issue?

kmMat4* kmMat4Scaling(kmMat4* pOut, const kmScalar x, const kmScalar y,
kmScalar z)
kmMat4* kmMat4Translation(kmMat4* pOut, const kmScalar x,
kmScalar y, const kmScalar z)

const missing on scaling z and translation y

there may be others

TestMat3::test_mat3_axis_angle fails on PPC

Test suit fails to pass on macOS ppc:

Start testing: Jan 19 22:34 MYT
----------------------------------------------------------
1/1 Testing: kazmath_suite
1/1 Test: kazmath_suite
Command: "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_kazmath/kazmath/work/build/tests/kazmath_tests"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_kazmath/kazmath/work/build/tests
"kazmath_suite" start time: Jan 19 22:34 MYT
Output:
----------------------------------------------------------

Running 39 tests

    TestAABB::test_aabb_expand_to_contain                                   �[32m   OK   �[0m
�[0m    TestAABB::test_aabb_contains                                            �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_inverse                                             �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_transpose                                           �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_fill                                                �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_are_equal                                           �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_axis_angle                                          �[33m FAILED �[0m
        false is not true
        /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_kazmath/kazmath/work/kazmath-48dbc191da47880ea6708b0a7b3c7b69b6352cad/tests/test_mat3.h:102
        kmMat3Identity(&expected);

�[0m    TestMat3::test_mat3_identity                                            �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_is_identity                                         �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_scaling                                             �[32m   OK   �[0m
�[0m    TestMat3::test_mat3_translation                                         �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_inverse                                             �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_and_quaternion_consistency                          �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_transpose                                           �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_rotation_y                                          �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_rotation_z                                          �[32m   OK   �[0m
�[0m    TestMat4::test_mat4_handedness                                          �[32m   OK   �[0m
�[0m    TestPlane::test_plane_extraction_from_matrix                            �[32m   OK   �[0m
�[0m    TestPlane::test_three_plane_intersection                                �[32m   OK   �[0m
�[0m    TestQuaternion::test_quaternion_multiply_vec3                           �[32m   OK   �[0m
�[0m    TestQuaternion::test_quaternion_slerp_edge_case                         �[32m   OK   �[0m
�[0m    TestQuaternion::test_quaternion_get_up_vector                           �[32m   OK   �[0m
�[0m    TestQuaternion::test_rotation_around_axis                               �[32m   OK   �[0m
�[0m    TestQuaternion::test_look_rotation                                      �[32m   OK   �[0m
�[0m    TestQuaternion::test_quaternion_axis_angle_conversion                   �[32m   OK   �[0m
�[0m    TestQuaternion::test_extract_rotation_around_axis                       �[32m   OK   �[0m
�[0m    TestRay2::test_line_segment_intersection                                �[32m   OK   �[0m
�[0m    TestRay2::test_triangle_intersection                                    �[32m   OK   �[0m
�[0m    TestRay3::test_ray_aabb_intersection                                    �[32m   OK   �[0m
�[0m    TestRay3::test_ray_plane_intersection                                   �[32m   OK   �[0m
�[0m    TestRay3::test_ray_triangle_intersection                                �[32m   OK   �[0m
�[0m    TestVec2::test_transform                                                �[32m   OK   �[0m
�[0m    TestVec2::test_vec2_reflect                                             �[32m   OK   �[0m
�[0m    TestVec2::test_degrees_between                                          �[32m   OK   �[0m
�[0m    TestVec2::test_vec2_rotate_by                                           �[32m   OK   �[0m
�[0m    TestVec3::test_project_onto_plane                                       �[32m   OK   �[0m
�[0m    TestVec3::test_vec3_reflect                                             �[32m   OK   �[0m
�[0m    TestVec3::test_vec3_project_onto_vec3                                   �[32m   OK   �[0m
�[0m    TestVec3::test_vec3_project_onto_plane                                  �[32m   OK   �[0m
�[0m-----------------------
1 tests failed

<end of output>
Test time =   0.04 sec
----------------------------------------------------------
Test Failed.
"kazmath_suite" end time: Jan 19 22:34 MYT
"kazmath_suite" time elapsed: 00:00:00
----------------------------------------------------------

End testing: Jan 19 22:34 MYT

10.6.8 Rosetta (ppc32), GCC 12.2.0, CMake 3.25.1

test_quaternion.h fails

'make' command error: "isnan was not declared in this scope"

Fix could be adding the line:
using std::isnan;
right after the includes in the same file.

Trouble compiling in Linux

I am running Arch Linux and am getting the following error after running 'make':

[ 46%] Built target kazmath [ 50%] Generating ../../tests/main.cpp Traceback (most recent call last): File "../../bin/kaztest_gen", line 8, in <module> parser.add_argument("--output", type=unicode, nargs=1, help="The output source file for the generated test main()", required=True) NameError: name 'unicode' is not defined make[2]: *** [tests/CMakeFiles/kazmath_tests.dir/build.make:72: ../tests/main.cpp] Error 1 make[1]: *** [CMakeFiles/Makefile2:140: tests/CMakeFiles/kazmath_tests.dir/all] Error 2 make: *** [Makefile:161: all] Error 2

Any help would be appreciated.

minor typo in Java wrapper

kazmath/java/kazmath/jkazmath.java:165: error: cannot find symbol Floatbuffer
public static native boolean kmAABBIntersectsAABB(FloatBuffer box, Floatbuffer to_check);

Floatbuffer should be FloatBuffer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.