matrix-multiplication

How do you combine X, Y, and Z rotations in a model's local space (not global)?

房东的猫 提交于 2019-12-22 04:18:05
问题 I am starting out on Molehill and am having a lot of problems grasping Matrix3D. My first problem is how to manage a Matrix3D that describes a single model's orientation. I use Matrix3D.appendRotation() to do this. But depending on the order I append in I get a different result (obviously, since I am rotating one at a time in the global space). I know this is a common problem, I have run into it with 3d software modeling. But this time, I have to fix it programtically. This is where I need

Why is the performance of these matrix multiplications so different?

谁都会走 提交于 2019-12-22 03:22:57
问题 I wrote two matrix classes in Java just to compare the performance of their matrix multiplications. One class (Mat1) stores a double[][] A member where row i of the matrix is A[i] . The other class (Mat2) stores A and T where T is the transpose of A . Let's say we have a square matrix M and we want the product of M.mult(M) . Call the product P . When M is a Mat1 instance the algorithm used was the straightforward one: P[i][j] += M.A[i][k] * M.A[k][j] for k in range(0, M.A.length) In the case

Unproject results for object picking

半城伤御伤魂 提交于 2019-12-21 21:27:51
问题 There are several references to this around the web, including from stackoverflow. I have an unproject method which returns x,y coordinates which are returning in range of -1 and 1. Im wondering if these values are correct. If so, then what do i do with these values, multiply b the cameras position? Reference: How to convert mouse coordinate on screen to 3D coordinate Updated I found a bug in my matrix library, where I was missing some matrix components, I think it was in the multiplication

Rotate a node using pan gesture in SceneKit iOS

北战南征 提交于 2019-12-21 20:21:53
问题 I am using the below code to rotate a node using the pan gesture. I like to rotate my node only in the y-axis. let translation = gestureRecognize.translation(in: gestureRecognize.view!) let x = Float(translation.x) let y = Float(-translation.y) let anglePan = (sqrt(pow(x,2)+pow(y,2)))*(Float)(Double.pi)/180.0 var rotationVector = SCNVector4() rotationVector.x = 0.0 rotationVector.y = x rotationVector.z = 0.0 rotationVector.w = anglePan node.rotation = rotationVector if(gestureRecognize.state

Tetranacci Numbers in Log(n)

偶尔善良 提交于 2019-12-21 18:45:48
问题 I have stumbled upon a problem, which requires me to calculate the nth Tetranacci Number in O(log n). I have seen several solutions for doing this for Fibonacci Numbers I was looking to follow a similar procedure (Matrix Multiplication/Fast Doubling) to achieve this, but I am not sure how to do it exactly (take a 4 by 4 matrix and 1 by 4 in a similar fashion doesn't seem to work). With dynamic programming/general loops/any other basic idea, I am not able to achieve sub-linear runtime. Any

Tetranacci Numbers in Log(n)

自闭症网瘾萝莉.ら 提交于 2019-12-21 18:45:32
问题 I have stumbled upon a problem, which requires me to calculate the nth Tetranacci Number in O(log n). I have seen several solutions for doing this for Fibonacci Numbers I was looking to follow a similar procedure (Matrix Multiplication/Fast Doubling) to achieve this, but I am not sure how to do it exactly (take a 4 by 4 matrix and 1 by 4 in a similar fashion doesn't seem to work). With dynamic programming/general loops/any other basic idea, I am not able to achieve sub-linear runtime. Any

Make efficient - A symmetric matrix multiplication with two vectors in c#

北慕城南 提交于 2019-12-21 12:27:53
问题 As per following the inital thread make efficient the copy of symmetric matrix in c-sharp from cMinor. I would be quite interesting with some inputs in how to build a symmetric square matrix multiplication with one line vector and one column vector by using an array implementation of the matrix, instead of the classical long s = 0; List<double> columnVector = new List<double>(N); List<double> lineVector = new List<double>(N); //- init. vectors and symmetric square matrix m for (int i=0; i < N

Boolean Matrix Multiplication in Matlab

别等时光非礼了梦想. 提交于 2019-12-21 12:22:54
问题 Does Matlab have a Boolean (sometimes called logical or binary) matrix multiplication function? I'm specifically talking about what's usually denoted by a circle with a dot in it to denote Boolean matrix multiplication: cij = (ai1 & b1j) || (ai2 & b2j) || (ai3 & b3j)|| ... || (aik & bkj) I have had a hard time locating one and am now assuming one does not exist. If that is the case, is there a quick way to write a .m file that will accomplish this task? An example would be: [1 1 1; [1 0 1; [1

find the dot product of sub-arrays in numpy

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 04:10:13
问题 In numpy, the numpy.dot() function can be used to calculate the matrix product of two 2D arrays. I have two 3D arrays X and Y (say), and I'd like to calculate the matrix Z where Z[i] == numpy.dot(X[i], Y[i]) for all i . Is this possible to do non-iteratively? 回答1: How about: from numpy.core.umath_tests import inner1d Z = inner1d(X,Y) For example: X = np.random.normal(size=(10,5)) Y = np.random.normal(size=(10,5)) Z1 = inner1d(X,Y) Z2 = [np.dot(X[k],Y[k]) for k in range(10)] print np.allclose

How is convolution done with RGB channel?

感情迁移 提交于 2019-12-21 03:35:28
问题 Say we have a single channel image (5x5) A = [ 1 2 3 4 5 6 7 8 9 2 1 4 5 6 3 4 5 6 7 4 3 4 5 6 2 ] And a filter K (2x2) K = [ 1 1 1 1 ] An example of applying convolution (let us take the first 2x2 from A) would be 1*1 + 2*1 + 6*1 + 7*1 = 16 This is very straightforward. But let us introduce a depth factor to matrix A i.e., RGB image with 3 channels or even conv layers in a deep network (with depth = 512 maybe). How would the convolution operation be done with the same filter ? A similiar