Simple python 3D vector3 math library wrapping some types from GLM library using pybind11.

Overview

vmath

Simple python 3D vector3 math library wrapping some types from GLM library using pybind11.

Description

Both pure python version and C++ version provided.

Not a direct glm wrapping. There are some Object-Oriented enhencements to the types.

Should be useful for other pybind11 bindings that use glm types, the conversion will be automatic (if done right).

Types:

  • Vector3 - glm::vec3
  • Quaternion - glm::quat
  • Matrix4 - glm::mat4
  • Transform - translation-rotation-scale
  • Vector2 - glm::vec2
  • Vector4 - glm::vec4
  • Ray - position-direction

Main source files comes from:

  • toy/wrap/wrap_vmath.h
  • toy/wrap/wrap_vmath.cpp
  • toy/glm_util.h
  • toy/glm_util.cpp

Documentation

See vmath.py for interfaces.

See src/wrap_vmath.cpp for pybind11 binding code.

Usage

Main classes:

  • Vector3: 3D Vector3.
  • Matrix4: 4x4 column major matrix4, M1 * M2 means first apply M2, then apply M1.
  • Quaternion: Quaternion for rotation.
  • Transform: Transform represented as Translation-Rotation-Scale.
>>> from vmath import Vector3, Matrix4, Quaternion, Transform
>>> v1 = Vector3(1.0, 2.0, 3.0)
>>> v2 = Vector3(4.0, 5.0, 6.0)
>>> v1 + v2
Vector3(5.0000, 7.0000, 9.0000)

>>> q = Quaternion.from_euler_angles(Vector3(0.0, 0.8, 0.0))
>>> q
Quaternion(0.9211, 0.0000, 0.3894, 0.0000)

>>> xf = Transform(v1, q, Vector3(1.0, 1.0, 1.0))
>>> m = xf.to_matrix4()
>>> print(m)
Matrix4<0.6967, 0.0000, 0.7174, 1.0000
       0.0000, 1.0000, 0.0000, 2.0000
       -0.7174, 0.0000, 0.6967, 3.0000
       0.0000, 0.0000, 0.0000, 1.0000>

>>> m.decompose()
Transform(Vector3(1.0000, 2.0000, 3.0000), Quaternion(0.9211, 0.0000, 0.3894, 0.0000), Vector3(1.0000, 1.0000, 1.0000))

>>> m.transform_vector3(v1)
Vector3(2.8488, 2.0000, 1.3728)
>>> m.transform_point(v1)
Vector3(3.8488, 4.0000, 4.3728)

Euler angles should be stored in Vector3(pitch, yaw, roll), order yaw-pitch-roll. Therefore the corresponding rotation matrix4 is M(yaw) * M(pitch) * M(roll).

Automatic conversion

One may want to use pybind11 binded glm types in multiple different extension modules, or embedded modules.

The conversion should just works thanks to internal pybind11 mechanisms, but with some carvets. Some notes:

  • Don't mix Debug and Release extension modules. The types won't be recongnised as the same by pybind11.

  • If one want more control, just drop the cpp files in the target project and compile _vmath as builtin (embedded) as vmath.

Build

Checkout pip_install_debug.bat file. One need to provide GLM path to build the extension.

Note

The interface of the types between the pure python module and extension module is somewhat different.

License

MIT License.

EL JUEGO DEL GUSANITO

EL JUEGO DEL GUSANITO El juego consiste en una línea que no para de moverse, el usuario lo controla con las flechas de: → derecha ← izquierda ↑ arriba

Valeria Saidid Miranda Ibarra 0 Dec 19, 2021
Setup minecraft server (Tuinity) to your directory

hapeshiva server-setup Setup minecraft server (Tuinity) for you. Support for optimization Create optimized yml Customazible server port and view dista

3 May 11, 2022
An environment to run atari-like games in VGDL.

vgdl An environment to run atari-like games in VGDL. Requirements python = 3.6 Installation pip install -r requirements.txt Usage # Create an enviro

Sergio Arnaud Gomez 1 Dec 24, 2021
A first-person shooting game developed by using OpenGL

OpenGL-MazeSurvivor-FirstPerson Shooting Game This application named ‘MAZE SURVIVOR’ is a first-person shooting game that finished within a month. It

JunHong 2 Jan 04, 2023
A very simple 3D maze game with ray tracing.

PytracingMaze MOST RECENT VERSION: Pytracing Maze.py Also, executable for Windows available on itch.io Simple ray tracing game in Python, based on my

FinFET 15 Dec 20, 2022
A hangman game that I created. Thanks to Data Flair for giving me the code!

Hangman A hangman game that I created. Thanks to Data Flair for giving me the code! Run python3 hangman.py in a terminal if you have Python 3. Please

SmashedFrenzy16 0 Dec 24, 2022
Official PyTorch implementation of NAC from the paper: Neural Auto-Curricula in Two-Player Zero-Sum Games.

NAC Official PyTorch implementation of NAC from the paper: Neural Auto-Curricula in Two-Player Zero-Sum Games. We release code for: Gradient based ora

Xidong Feng 19 Nov 11, 2022
The Original Snake Game. Maneuver a snake in its burrow and earn points while avoiding the snake itself and the walls of the snake burrow.

Maneuver a snake in its burrow and earn points while avoiding the snake itself and the walls of the snake burrow. The snake grows when it eats an apple by default which can be disabled in the setting

17 Nov 12, 2022
DouZero_For_HLDDZ_FullAuto: 将DouZero用于欢乐斗地主自动化

DouZero_For_HLDDZ_FullAuto: 将DouZero用于欢乐斗地主自动化 本项目基于DouZero 和 DouZero_For_Happy_DouDiZhu 环境配置请移步项目DouZero 模型默认为ADP,更换模型请修改main.py中的模型路径 运行main.py即可 在原

322 Dec 25, 2022
Launch any Heroic-Games-Launcher game using bash scripts without having to open Heroic.

HeroicBashLauncher Ever wanted to launch your EGS games installed through Heroic Games Launcher directly from the terminal, Lutris or any other fronte

288 Dec 27, 2022
Open-source project written in the ursina engine, simulating the popular game Minecraft.

Voxelcraft is an open-source project written in the ursina engine, simulating the popular game Minecraft.

Calinescu Mihai 21 Oct 06, 2022
A comprehensive, feature-rich, open source, and portable, collection of Solitaire games.

PySol Fan Club edition This is an open source and portable (Windows, Linux and Mac OS X) collection of Card Solitaire/Patience games written in Python

Shlomi Fish 368 Dec 28, 2022
Recreation of HexGame in Pygame. More features will come soon !

Hex with Pygame Historical point of view What Are the rules of this game ? Some Strategies and tips The algorithm for the Win Other fonctionnalities W

4 Mar 26, 2022
Wordle - Wordle Clone With Python

Wordle Clone Python This is a cli clone of the famous wordle game developed by J

Shivam Pandya 20 Jul 07, 2022
A Pygame Hangman Game coded in Python 3. Run Hangman.py in a terminal if you have Python 3

Hangman A Pygame Hangman Game coded in Python 3. Run python3 Hangman.py in a terminal if you have Python 3.

1 Dec 24, 2022
Code and outputs from analysis determining that the wordle game can always be won in six moves.

wordle_worst_case_analysis Code and outputs from analysis determining that the wordle game can always be won in six moves. This is for the general cas

2 Aug 19, 2022
This is a good project to train your logic game with python language

JO-KEN-PÔ!!! | Description | basic. I make this game only to train. This is a good project to train your logic game with python language. This game is

Elianderson Silva 1 Jan 24, 2022
Among AIs is a (prototype of) PC Game we developed as part of the Smart Applications course @ University of Pisa.

Among AIs is a PC Game we developed as part of the Smart Applications course @ Department of Computer Science of University of Pisa, under t

Gabriele Pisciotta 5 Dec 05, 2021
Repository for the DecodED2 Game Project!

DecodED2 Game Project Hello everyone! Welcome to the GitHub Repository for DecodED2, as a start you'll need to clone this repository and make sure you

6 Sep 29, 2021
This is a script which can be used to autobattle, upgrade metamon, compose eggs and open eggs in metamon game.

This is a script which can be used to autobattle, upgrade metamon, compose eggs and open eggs in metamon game. The only parameters you need to input are you wallet address and sign. The sign can be o

Taxiria 37 May 11, 2022