matrix

BitmapData.draw() Matrix problem

Hello, I've run into an issue where the BitmapData.draw() method isn't accurately subtracting image data from a .png that uses transparency. I've put together a test file that shows this behavior, it's located here: http://www.filedropper.com/shield_1 In a nutshell, a sprite drops from the top of the screen and when it intersects with...

Create a bigger matrix from smaller one

Hi all, I have a matrix A which is: A <- matrix(c(1:15), byrow=T, nrow=5) A [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [4,] 10 11 12 [5,] 13 14 15 Now I want to create a matrix B, which is 8x8 dimensions (or 10x10, or 15x15, etc), which would look like this: [,1] [,2] [,3] [,4] [,...

Plotting RGB spectrum as 2-d color matrix?

Any suggestions on how I might go about plotting the RGB color space as a 2-D matrix? I need a theoretical description of what's going on; a code sample or pseudocode would be helpful but is not required. Thanks! ...

OpenGL MODELVIEW rotations manually

Hello, For my graphics class, our professor wants us to keep track of our current matrix on our own and apply rotations/translations/scaling matrices to it then load it using glMatrixMode(GL_MODELVIEW) and glLoadMatrix(current_matrix). All of this seems fine, but when I actually use it, I keep having an issue: if I apply a rotation to ...

Filling an evenly distributed matrix of arrays with PHP

I have an array of objects, containing lists of times. I have to stick this in a Matrix-alike array, in order to put it in a table. This is a part of my earlier SO question on how to build calendar tables $node->sessions = array( 1286452800, // '2010-10-07 14:00:00' 1286460000, // '2010-10-07 16:00:00' ); $node->title = 'Foo'; $node...

Ray transformation for ray-triangle intersection

In openGL, I have a 3D model I'm performing a ray-triangle intersection on, using the code explained in the paper "Fast, Minimum Storage Ray/Triangle Intersection" ( http://jgt.akpeters.com/papers/MollerTrumbore97/ ). My cursor position is unprojected into world space using the following code: bool SCamera::unproject(Vector3 input, Ve...

matlab: how to plot multidimensional array

Hello, Let's say I have 9 MxN black and white images that are in some way related to one another (i.e. time lapse of some event). What is a way that I can display all of these images on one surface plot? Assume the MxN matrices only contain 0's and 1's. Assume the images simply contain white lines on a black background (i.e. pixel valu...

Creating an Object [multiple of same instance]

I created an Matrix object (like the math Matrix, a 4x4 block of numbers for instance) and it works fine, can set row,col,variable just fine, but, I cant have more than one of the same object, I have it creating an ArrayList of a dozen Matrix objects, each with the three variables, but when I call changeVar(Matrix x,int variable) and ref...

difference between methods to scale a bitmap

Hi, There are at least two methods to scale a bitmap in Android, One is to use "inScaled, inDensity, inTargetDensity" in "BitmapFactory.Options" when decode a bitmap source. The other is to use a "Matrix" in "Bitmap.createBitmap". What I am curious is what the difference between these two method is? What about the quality of produced b...

R: Plotting a 3D surface from x, y, z

Hello imagine I have a 3 columns matrix x, y, z where z is a function of x and y. I know how to plot a "scatter plot" of these points with plot3d(x,y,z) But if I want a surface instead I must use other commands such as surface3d The problem is that it doesn't accept the same inputs as plot3d it seems to need a matrix with (nº elem...

Print a x,y matrix, java

I want to print the followin matrix using for loops: 1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5 I use: public static void main ( String [ ] args ) { for(int w = 1; w <= 6; w++){ System.out.println(""); for(int p = w; p <= 6; p++){ System.out.print(p + ""); } ...

How to represent a 4x4 matrix rotation?

Given the following definitions for x,y,z rotation matrices, how do I represent this as one complete matrix? Simply multiply x, y, & matrices? X Rotation: [1 0 0 0] [0 cos(-X Angle) -sin(-X Angle) 0] [0 sin(-X Angle) cos(-X Angle) 0] [0 0 0 1] Y Rotation: [cos(-Y Angle) 0 sin(-Y Angle) 0] [0 1 0 0] [-sin(-Y Angle) 0 cos(-Y Ang...

MATLAB matrix not formatting correctly

Hi everyone, I have some code below, and I cant seem to get the matrices formatted correctly. I have been trying to get the matrices to look more professional (close together) with \t and fprintf, but cant seem to do so. I am also having some trouble putting titles for each columns of the matrix. Any help would be much appreciated! cle...

Algorithm for filling a matrix of item, item pairs

Hey guys, I have a sort of speed dating type application (not used for dating, just a similar concept) that compares users and matches them in a round based event. Currently I am storing each user to user comparison (using cosine similarity) and then finding a round in which both users are available. My current set up works fine for sma...

Domize algorithm

I'm trying to figure out how http://domize.com codes their site for speed (I'm using C#). For example, if I search for [cns][vwl][cns][cns][vwl][cns] This will search for a 6 letter domain name that is in this order consonant, vowel, consonant, consonant, vowel, consonant Resulting in: babbab babbac babbad babbaf ... zuzzux zuzzuy ...

Implement flood-fill in wpf c#

Hi, I am trying to implement flood-fill on a 2d matrix. It is similar to the fill color of MS Paint or any other painting application. Following is the code void FloodFill(int x, int y, Color targetColor, Color replacementColor) { LinkedList<Point> check = new LinkedList<Point>(); if (targetColor != replacementColo...

C++ matrix size depending input doesn't compile

Hi, there is a topic about this subject which is working with arrays but I can't make it work with matrices. (Topic: http://stackoverflow.com/questions/312116/c-array-size-dependent-on-function-parameter-causes-compile-errors) In summary: long rows, columns; cin >> rows >> columns; char *a = new char [rows]; compiles grea...

What is the best way to extract a diagonal from a matrix in Haskell?

I was asked to write a function that would extract the diagonal of a matrix stored as a list of lists. The first version was to extract the number by indexing the lists, but I soon concluded it isn't a good algorithm for Haskell and wrote another function: getDiagonal :: (Num a) => [[a]] -> [a] getDiagonal [[]] = [] getDiagonal (x...

Rotating array differently

hey, I need to rotate a 2d array in such way : 4X4--> Input Output 1 2 3 4 5 1 2 3 5 6 7 8 1 2 6 4 1 2 3 4 5 3 7 8 5 6 7 8 6 7 8 4 or for odd 5X5--> Input Output 1 2 3 4 5 6 1 2 3 4 6 7 8 9 10 1 2 7 8 5 1 2 3 4 5 6 7 3 9 10 6 7 8 9 10 1 8 9 4 5 1 2 3 4 5 2 3 4 5 10 can someone help me? as ...

Converting a matrix in MATLAB

Let's say I've got a vector a = [1 2 4]. I want it converted into a vector which looks like this b = [1 2 0 4], i.e. each number is placed into a correct position and since 3 is not included into the vector a, it is replaced by 0 in vector b. This can be done the following way: a = [1 2 4] b = zeros(1, size(a, 2)); b(1, a) = a; I can'...