quaternions | This is a library for dealing with quaternions python | Data Manipulation library

 by   satellogic Python Version: v0.1.6 License: GPL-3.0

kandi X-RAY | quaternions Summary

kandi X-RAY | quaternions Summary

quaternions is a Python library typically used in Utilities, Data Manipulation, Numpy applications. quaternions has no bugs, it has no vulnerabilities, it has build file available, it has a Strong Copyleft License and it has low support. You can download it from GitHub.

[Build Status] This is a library for dealing with quaternions in python in a unified way. ~~Most of~~ all the quaternions we use are unitary (not like the example above).
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              quaternions has a low active ecosystem.
              It has 11 star(s) with 6 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 9 open issues and 7 have been closed. On average issues are closed in 19 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of quaternions is v0.1.6

            kandi-Quality Quality

              quaternions has 0 bugs and 0 code smells.

            kandi-Security Security

              quaternions has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              quaternions code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              quaternions is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              quaternions releases are available to install and integrate.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed quaternions and discovered the below as its top functions. This is intended to give you an instant insight into quaternions implemented functionality, and help decide if they suit your requirements.
            • Convenience constructor for a quaternion
            • Return the first eigenvalue of a matrix
            • Average Quaternion
            • Compute the center of quaternions
            • Returns the cross product of a quaternion
            • Return the xi matrix of the quaternion
            • Calculate the average and standard deviation between quaternions
            • Calculate the covariance matrix from a list of angles
            • Calculates the sigma - Leibler divergence coefficient
            • Convert ra and roll to quaternion
            • Expand a quaternion
            • Validates that q is a quaternion
            • Exponential exp
            • Average Quaternions
            • Return the rotation angle in radians
            • Return the rotation angle between self and other
            • Returns the ra and roll of the ra
            • Quaternion first
            • Integrate a rotation vector
            • Return a unit
            • The rotation vector
            • Return the log of a quaternion
            • Logs the event
            • Square norm
            Get all kandi verified functions for this library.

            quaternions Key Features

            No Key Features are available at this moment for quaternions.

            quaternions Examples and Code Snippets

            No Code Snippets are available at this moment for quaternions.

            Community Discussions

            QUESTION

            How to correctly transform Quaternion to itself
            Asked 2022-Apr-12 at 10:48

            In Unity project I have to convert Quaternion class to Vector3 and then convert back into Quaternion.

            So I wrote the code:

            ...

            ANSWER

            Answered 2022-Apr-12 at 09:41

            first off, odd way to debug something in Unity.

            And now to the question. Why are you trying to convert something to something else and then back to itself? According to your code you are not changing the created Vector3, so why not just use the original Quaternion?

            EulerAngles can't really hold as much information about the rotation of a Quaternion than the Quaternion itself, so It's very likely that information can get lost or altered when working with Eulers.

            Here are the two links to Unity-Documentation that you might wanna look at. The first explains, why working with EulerAngles tends to be inconsistent and the other might have a solution for whatever it is you're trying to do.

            https://docs.unity3d.com/ScriptReference/Quaternion-eulerAngles.html

            https://docs.unity3d.com/ScriptReference/Quaternion-operator_multiply.html

            Source https://stackoverflow.com/questions/71838478

            QUESTION

            How to join two box geometries?
            Asked 2022-Apr-02 at 08:45

            I want to join 2 Box Geometries to each other (image below) which are than drag rotatable as one object. Below is the code for one drag-rotatable boxgeometry ( var geometry1 ), what do I need to add to the code, so that the second box geometry ( var geometry2 ) is joined to the first?

            ...

            ANSWER

            Answered 2021-Dec-20 at 16:06

            You can create a group:

            Source https://stackoverflow.com/questions/70421793

            QUESTION

            DXF files - How does the normal vector and position relative to this provide full understanding of block position
            Asked 2022-Mar-09 at 06:32

            I have been scratching my head for days understanding how to fully describe a block to insert in DXF. For background I am interested in the rules and behaviour of how to do this, not simply trying to find an existing library.

            I can create a block in dxf, lets say this is a simple cube. I can then in the Entities section insert this block. To do this I enter the coordinates relative to the object coordinate system codes:(10, 20, 30), and the normal vector of the object codes:(210,220,230). There is also a value to rotate about the normal vector code: 50.

            So there are two things to do:

            1. Calculate the normal vector for my object
            2. Calculate the object co-ordinates, given the world coordinates for the object.

            To calculate the normal vector, I use quaternions to calculate the rotation applied to the world z-axis (0,0,1) if a yaw, pitch, or roll angle is applied (if not, I simply use the world z-axis). I can use the same quaternions to calculate the arbitrary x and y axis using the same rotation for each of the real world x and y axes. For those looking for more info, this link has a very clear explanation of how to calculate them. https://danceswithcode.net/engineeringnotes/quaternions/quaternions.html

            To help you, this calculator can help confirm if this has been implemented correctly or not by checking the results:

            Rotation calculator

            Then to calculate the object co-ordinates I simply cross multiply the world coordinate with each of the arbitrary axes/normal axes.

            For most scenarios this appears to work. However I am left at a loss for additional rules and requirements which I cannot see documented anywhere:

            1. If only a yaw angle is applied (rotation about z), then the normal is still (0,0,1). We need to apply a rotation about z in the scenario that pitch and roll are zero.

            2. If I alter the pitch, the normal vector can change from a negative y-coordinate to a positive one. This change in slope appears to affect the direction the vector is headed and if positive, requires a rotation about the normal of 180 degrees to correct it.

            3. For some unknown reason when I apply a roll angle, my object is rotated around the normal by 90 degrees, and I need to apply a correction here.

            I am struggling to find any more clear direction on this online. Does anyone have any thorough explanations that describe the behaviour above, or any pointer material?

            ...

            ANSWER

            Answered 2022-Mar-09 at 06:32

            As suggested in another topic, a little matrix calculus can solve this issue.

            Shortly, they are mainly two ways to describe the same Euler angles:

            • Tait-Bryan angles (yaw, pitch, roll) rotations about X, Y, Z axis;
            • Proper Euler angles (precession, nutation, intrisic rotation) rotations about Z, X, Z axis; AutoCAD uses the second one to describe a bloc orientation. The combination of precession and nutation provides the OCS transformation matrix and the intrinsic rotation is the rotation value of the block.

            A little F# example with 3x3 matrices to describe 3d rotations.

            Source https://stackoverflow.com/questions/71267982

            QUESTION

            Smooth 2d turret rotation accounting for wrapping
            Asked 2022-Feb-17 at 14:38

            I wish to make a turret in a 2d game, which should rotate smoothly to the angle of the mouse. I came up with two solutions but neither are satifactory. The first:

            ...

            ANSWER

            Answered 2022-Feb-17 at 14:38

            I found a cheesed solution, after a long time! This was oddly challenging. I still feel like my solution was sub-optimal though

            It just checks which way is shorter

            Source https://stackoverflow.com/questions/71150241

            QUESTION

            How to move a glTF model in the direction it is facing in A-frame?
            Asked 2022-Feb-11 at 10:24

            I have a gltf model of my robot loaded in A-frame scene version 1.0.4. So far I can turn the robot about its x,y, z axes, but when I try to move it forward it still moves in its initial direction rather than the direction it's facing. I want to be able to control its movements with my keyboard without using any external libraries. I believe I have to use Quaternions, but I haven't figured out how to use them yet. Here is my A-frame code so far.

            ...

            ANSWER

            Answered 2022-Feb-05 at 18:56

            Yes, using quatenions is a good way to solve this.

            You can simply apply the robot's current quaternion to a vector3 representing the movement you want to make in the robt's original rotation, and apply that to the robot's position.

            Something like this:

            Source https://stackoverflow.com/questions/70999742

            QUESTION

            How to calculate the quaternions of all 24 rotations of a cube?
            Asked 2022-Jan-18 at 23:26

            Similar to these two previous questions (How to calculate all 24 rotations of 3d array?, How to get all 24 rotations of a 3-dimensional array?), I want to find the all the 90 degree rotations of an object. However, I need the quaternions of those rotations.

            ...

            ANSWER

            Answered 2022-Jan-18 at 23:23
            import numpy as np
            import itertools
            from pyquaternion import Quaternion
            
            
            def rotations():
                for x, y, z in itertools.permutations([0, 1, 2]):
                    for sx, sy, sz in itertools.product([-1, 1], repeat=3):
                        rotation_matrix = np.zeros((3, 3))
                        rotation_matrix[0, x] = sx
                        rotation_matrix[1, y] = sy
                        rotation_matrix[2, z] = sz
                        if np.linalg.det(rotation_matrix) == 1:
                            quat = Quaternion(matrix=rotation_matrix)
                            yield quat.elements
            
            
            all_rotations = list(rotations())
            
            print(len(all_rotations))
            for x in all_rotations:
                print(x)
            

            Source https://stackoverflow.com/questions/70755388

            QUESTION

            Unity - completely wrap sphere with 64+ individual earth-satellite tiles loaded from web
            Asked 2022-Jan-10 at 23:37

            Scenario

            I'm using unity c# to re-invent a google-earth like experience as a project. New tiles are asynchronously loaded in from the web while a user pans the camera around the globe. So far I'm able to load in all the TMS tiles based on their x & y coordinates and zoom level. Currently I'm using tile x,y to try and figure out where the tile should appear on my earth "sphere" and it's becoming quite tedious, I assume because of the differences between Euler angles and quaternions.

            • I'm using the angle of Camera.main to figure out which tiles should be viewed at any moment (seems to be working fine)
            • I have to load / unload tiles for memory management as level 10 can receive over 1 million 512x512 tiles
            • I'm trying to turn a downloaded tile's x,y coordinates (2d) into a 3d position & rotation

            Question

            Using just the TMS coordinates of my tile (0,0 - 63,63) how can I calculate the tile's xyz "earth" position as well as its xyz rotation?

            Extra

            • in the attached screenshot I'm at zoom level 4 (64 tiles)
            • y axis 0 is the bottom of the globe while y axis 15 is the top
            • I'm mostly using Mathf.Sin and Mathf.Cos to figure out position & rotation so far

            ** EDIT **

            I've figured out how to get the tile position correct. Now I'm stuck on the correct rotation of the tiles.

            The code that helped me the most was found with a question about generating a sphere in python.

            I modified to the code to look like so:

            ...

            ANSWER

            Answered 2021-Dec-07 at 21:20

            For the positioning and rotation of the planes, you can do that in c#:

            Source https://stackoverflow.com/questions/70162448

            QUESTION

            Search paths "/usr/local/include/glm/gtx" versus Use of undeclared identifier 'gtx'
            Asked 2022-Jan-07 at 20:52

            Mac Big Sur C++ OpenGL attempting to learn quaternions from a tutorial. The gtx headers are under usr/local/include/glm. Can anyone figure out what is wrong with my header includes or header search path? Thanks.

            Minimum reproducible code that fails for this issue:

            ...

            ANSWER

            Answered 2022-Jan-06 at 05:46

            In tutorial 1 of the link in the comment, the author introduces

            Source https://stackoverflow.com/questions/70602526

            QUESTION

            Spawning objects parallel to the terrain
            Asked 2022-Jan-05 at 04:42

            Story
            so I'm working on making a procedural terrain generator script to spawn rocks on the ground all the big rocks don't care what rotation they are but I have some small rocks that have to be parallel to the terrain or they look weird, part of them floating off the ground other part stuck in the ground the quaternions I don't seem to understand

            Problem
            i am getting the terrainData.GetInterpolatedNormal and putting it into a vector3 called normals then when i am spawning my rock i rotate it towards ground

            ...

            ANSWER

            Answered 2022-Jan-05 at 04:42

            Quaternions use compound(Imaginary) numbers to represent a sequence of rotations in 3d space.

            When you instantiate a new Quaternion using it's constructor you are providing it with what you think the Quaternion's real and imaginary numbers should be.

            Despite the seemingly familiar x, y, and z names you should not manually modify or provided them, they are not euler angles, cartesian coordinates, or traditional vector components.

            What you're currently passing it is portions of a direction instead of the real and imaginary parts of a Quaternion.

            A normal is an "outwards direction" from a given position. So to get a rotation we need some other direction to compare it to in order to get a rotation.

            Compare your direction with the up direction and you'll get a rotation that you can use.

            Source https://stackoverflow.com/questions/70587290

            QUESTION

            Rotating Parent to Make Child Face Opposite Direction of Target's Forward
            Asked 2022-Jan-03 at 07:17

            Scenario:

            • Parent P1 has Child C1
            • Target exists
            • All items' forward vectors face perfectly parallel to the X-Z Plane (pseudo 2D)
            • Positions of all objects are arbitrary
            • Child will never move on its own within Parent's space

            Goal:

            Rotate P1 exclusively about the Y-Axis to have C1 Face the opposite direction of target's forward vector

            Note: Y-Axis Positive would face reader, Negative would go into screen

            Implementation:

            ...

            ANSWER

            Answered 2022-Jan-03 at 07:17

            A simple way of representing this transform would be the targets rotation plus 180 degrees about the up axis, and that can be expressed as follows:

            Source https://stackoverflow.com/questions/70561528

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install quaternions

            You can download it from GitHub.
            You can use quaternions like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/satellogic/quaternions.git

          • CLI

            gh repo clone satellogic/quaternions

          • sshUrl

            git@github.com:satellogic/quaternions.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Data Manipulation Libraries

            Try Top Libraries by satellogic

            canopus

            by satellogicC

            orbit-predictor

            by satellogicPython

            telluric

            by satellogicJupyter Notebook

            grafana-3d-globe-panel

            by satellogicJavaScript

            open-impact

            by satellogicJupyter Notebook