math

Quaternion to matrix rotation only one axis

梦想的初衷 提交于 2020-03-05 05:17:42
问题 I have a quaternion that contains the rotation of the three axes (x, y, z) at the same time. I want to convert this quaternion to a rotation matrix but only the rotation on the Y axis of the quaternion or of any of the other axes, without all three at the same time. 回答1: A possible route: Transform unit vectors X=(1,0,0) and Z=(0,0,1) by the quaternion Call these rotated vectors (x0,x1,x2) and (z0,z1,z2) If the rotation would have been purely around Y, we would have: (x0,x1,x2) = (cos(theta),

Correct way of calculating the roll of an animal using 3d acceleration?

不羁岁月 提交于 2020-03-05 00:35:16
问题 I placed an accelerometer to several fishes in a field experiment to understand some of their behaviours. What I got was values of raw acceleration (X, Y, Z) of the fishes. This raw acceleration is decomposed into a part that is static (due to the gravity. I call it rmX , rmY and rmZ ) and a dynamic part (due to the movement of the fish. I call it diX , diY and diZ ). What I would like is to calculate the roll of my fishes in different circumstances (while swimming, resting, etc) since this

Correct way of calculating the roll of an animal using 3d acceleration?

狂风中的少年 提交于 2020-03-05 00:31:02
问题 I placed an accelerometer to several fishes in a field experiment to understand some of their behaviours. What I got was values of raw acceleration (X, Y, Z) of the fishes. This raw acceleration is decomposed into a part that is static (due to the gravity. I call it rmX , rmY and rmZ ) and a dynamic part (due to the movement of the fish. I call it diX , diY and diZ ). What I would like is to calculate the roll of my fishes in different circumstances (while swimming, resting, etc) since this

Calculating which mouse axis x or y to track from a given angle of a draggle item

房东的猫 提交于 2020-03-04 15:33:53
问题 Having been stuck on this for 4 days now, ive turned to the community for help. I am attempting to calculate the distance given from a point, given the angle off the wall, all distances to wall items are from the left. If dragging the item on wall A I know that I will need to track the mouse movement of the x axis If dragging the item on wall B I know that I will need to use a ratio of x and y to calculate the distance to the left If dragging the item on wall C I know that I will need to

Calculate fraction as value relative to other fractions

你。 提交于 2020-03-04 08:28:11
问题 Apologies that I can't show code I'm just not sure how to go about this. I would like to achieve something like display: flex/grid does with fractions: Given a container width: 200px And items: [0.5, 1, 50px] I should be able to calculate the fractional ones relative to each other: item1: 50 (half the size of item 2) item2: 100 (double the size of item 1) item3: 50 (static size not a fraction) const totalSize = 900; const items = [1, 0.2, 75, 0.6, 1, 100]; const totalStaticSize = items.filter

Calculate fraction as value relative to other fractions

淺唱寂寞╮ 提交于 2020-03-04 08:27:54
问题 Apologies that I can't show code I'm just not sure how to go about this. I would like to achieve something like display: flex/grid does with fractions: Given a container width: 200px And items: [0.5, 1, 50px] I should be able to calculate the fractional ones relative to each other: item1: 50 (half the size of item 2) item2: 100 (double the size of item 1) item3: 50 (static size not a fraction) const totalSize = 900; const items = [1, 0.2, 75, 0.6, 1, 100]; const totalStaticSize = items.filter

Calculate angle of triangle Python

我只是一个虾纸丫 提交于 2020-03-01 03:21:07
问题 I'm trying to find out the angle of the triangle in the following, I know it should be 90 degrees, however I don't know how to actually calculate it in the following: Here's what I've tried: angle = math.cos(7/9.899) angleToDegrees = math.degrees(angle) returns: 43.XX What am I doing wrong? 回答1: It's a little more compicated than that. You need to use the law of cosines >>> A = 7 >>> B = 7 >>> C = 9.899 >>> from math import acos, degrees >>> degrees(acos((A * A + B * B - C * C)/(2.0 * A * B))

Getting the rotation of device around the world origin's y axis in ARKit

对着背影说爱祢 提交于 2020-02-28 09:46:05
问题 I am trying to calculate the rotation of my device when I rotate it around the y-axis in ARKit. For clarification the y-axis in ARKit is the axis pointing upwards perpendicular to the ground. I used eulerangles to get the rotation of the camera like this: var alpha = sceneView.pointOfView?.eulerAngles.y This approximately works when 0=<alpha<pi/2 and when -pi/2<alpha<=0 , but for what is supposed to be other angles I get the wrong readings. I suspect this has to do with gimbal lock and that I

Vector Transformation with Matrix

廉价感情. 提交于 2020-02-28 08:49:07
问题 I'm working on a code to do a software skinner (bone/skin animation), and I'm at the "optimization" phase (the skinner works pretty well and skin a 4900 triangles mesh with 22 bones in 1.09 ms on a Core Duo 2 Ghz (notebook)). What I need to know is : 1) Can someone show me the way (maybe with pseudocode) to transform a float3 (array of 3 float) (representing a coordinate) against a float4x3 matrix? 2) Can someone show me the way (maybe with pseudocode) to transform a float3 (array of 3 float)

Vector Transformation with Matrix

好久不见. 提交于 2020-02-28 08:48:07
问题 I'm working on a code to do a software skinner (bone/skin animation), and I'm at the "optimization" phase (the skinner works pretty well and skin a 4900 triangles mesh with 22 bones in 1.09 ms on a Core Duo 2 Ghz (notebook)). What I need to know is : 1) Can someone show me the way (maybe with pseudocode) to transform a float3 (array of 3 float) (representing a coordinate) against a float4x3 matrix? 2) Can someone show me the way (maybe with pseudocode) to transform a float3 (array of 3 float)