matrix

drawing part of a bitmap on an Android canvas

How can you blit a non-rectangular (e.g. oval) part of a bitmap into a canvas on Android? Consider how you'd blit a rectangular part of a bitmap: canvas.DrawBitmap(src,src_rect,dest_rect,paint). Sadly there is no corresponding methods for non-rectangular regions. Four approaches present themselves (maybe you know a fifth?): copy the...

How can I scale at an anchor point using CGAffineTransform?

Edited to better explain my problem I am trying to perform a zoom operation using my custom view (not UIView). The view has translation, scale, rotate values. I use these as follows, between calls to glPushMatrix() and glPopMatrix(). - (void)transform { glTranslatef(translation.x + anchor.x, translation.y + anchor.y, 0.0f); //g...

Problem with positioning a copy of a QGraphicsPolygonItem in a QGraphicsScene

Hi. I have an application where a QGraphicsPolygonItem (objectA) has the following characteristics: ScenePos: X=250 Y=125 Transform(): |----|---|---| | 2 | 0 | 0 | | 0 | 1 | 0 | | 50 | 0 | 1 | |----|---|---| Now, I am creating and new QGraphicsPolygonItem (objectB) and setting its scenepos and Transform the same as object A: obj...

more efficient sparse matrix element accessor

Hi, I wrote a small sparse matrix class with the member: std::map<int,std::map<int,double> > sm; The method below is the function i use to access the elements of a matrix, if not possible through an iterator: double matrix::operator()(int r,int c) const { std::map<int,std::map<int,double> >::const_iterator i = sm.find(r); if(...

Translation problem while scaling an object

Hi, I have a QGraphicsPolygonItem defined as: myShape << QPointF(-50, -50) << QPointF(50, -50) << QPointF(50, 50) << QPointF(-50, 50) << QPointF(-50, -50); mypolygon.setPolygon(myShape); Its starting matrix is identity: |---|---|---| | 1 | 0 | 0 | | 0 | 1 | 0 | | 0 | 0 | 1 | |---...

Android: Matrix -> what is the different between preconcat and postconcat?

I'm using Matrix to scale and rotate Bitmaps. Now I'm wondering what the difference between preconcat & postconcat is, or more precisely the difference between: postRotate preRotate setRotate From what I could figure out so far setRotate always overwrites the whole matrix, while with preRotate and postRotate I can apply multiple chan...

C++ library for calculating the matrix exponential

Any recommendations for libraries to implement calculation of the matrix exponential? ...

How do I rotate vectors using matrices in Processing ?

I am trying to rotate vectors using matrices, but got confused. I thought all I needed to do is create a rotation matrix and multiply it to a vector to get the rotated vector. Here you can see a simple test I've done using Processing: Use a to increment rotation, and x/y/z to changes the axis. And here is source: PVector[] clone,f...

in or out of a for loop in R - calculating the diagonal product of a matrix

I'm trying to find the maximum diagonal product of 2 digit numbers in a 20x20 matrix. This gives an error message : i <- 17:1 z <- for (j in 1:(18-i)) {b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3]))}} But this doesn't: z <- for (i <- 17:1) {for (j in 1:(18-i)) {b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3...

Matlab variable type help

How to convert variable of 'struct' type to a matrix in Matlab? How do we convert the q_yearly_w, in the code below, which is of type 'struct' to a matrix with which we can perform normal mathematical operations? %# open the file fid = fopen(Reportq_rwo); %# read it into one big array, row by row fileContents = textscan(fid,'%s','Deli...

R: Why this doesn't work?, matrix, rounding error?

Hello Why this works: ncota <- 1 nslope <- 29 resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4) But this doesn't? ncota <- 1 sini <- 0.1; sfin <- 1.5; spaso <- 0.05; nslope <- 1+((sfin-sini)/spaso) resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4) I guess the problem is that the division gives a noninteger number. How can ...

How can I transpose and "untranspose" a matrix?

I have this matrix: 1 2 3 4 5 6 and I transpose the matrix: 1 4 2 5 3 6 How can I get the original matrix back, after the transpose? "untranspose" = 1 2 3 4 5 6 I am making a simple cryptographic algorithm in Java and need that to solve that problem. ...

c++ convert matrix into row pointer vector

vector<vector<int> > mymatrix; vector<int> *ptr_vec; How do I make the ptr_vec point to the vectors which are inside mymatrix one after another. In more details Let's say mymatrix.at(0).size() gives 10, and mymatrix.at(1).size() gives 14 ..if I go ptr_vec->at(15) it should give me the fifth member in mymatrix.at(1) hope it doesn't conf...

MATLAB coding problem

Hey guys, I got this error message when I tried to trigger the function below. Can anybody help me out? Thanks! >> changeYuv('tilt.yuv',352,288,1:40,40); ??? Index exceeds matrix dimensions. Error in ==> changeYuv at 32 j=histogram(imgYuv(:,:,1,k+1)); >> [x,y,z,a]=size(imgYuv) x = 288 y = 352 z = 3 a = 40...

Scanning data matrix bar codes from motorola mc55 using data wedge

Hi i am developing an application in compact framework to be deployed on windows 6.5. I am looking for a solution to scan data matrix bar codes from Motorola mc55. I have installed data wedge in mc55 but it is only scanning linear bar codes. I am trying different complicated settings of data wedge to shift it to some other bode so that...

Hidden dynamic matrix groups still take space in SSRS

The Problem I am using dynamic matrix groups as in Dynamic Grouping from Chris Hays's Reporting Services Sleazy Hacks Weblog (which has some great stuff and is worth checking out, by the way). I have my row and column groups bound to two multi-value parameters and everything is working great, except for one thing. Even though I am suppr...

Modelling a price matrix table in MySQL

Hello good people of stackoverflow, I am trying to create an ecommerce product that takes orders for print jobs. I would like to create tables such as the ones here on solopress for example http://www.solopress.com/leaflet-printing/leaflets.html. I am just struggling a little with the logical steps of modelling this in a database. Firs...

Finding eigenvectors of covariance matrix to create 3D bounding sphere

I'm currently in the process of writing a function to find an "exact" bounding-sphere for a set of points in 3D space. I think I have a decent understanding of the process so far, but I've gotten stuck. Here's what I'm working with: A) Points in 3D space B) 3x3 covariance matrix stored in a 4x4 matrix class (referenced by cells m0,m1,m2...

How can I create a two-dimensional array in Perl?

I am currently trying to pass a matrix file that is 32 by 48 to a multi-dimensional array in Perl. I am able to access all of the values but am having issues accessing a specific value. I need to run specific statistics on each of the values, calculate zscore, subtract the mean from each value, penalize specific values et cetera. I tried...

How do I divide the rows of a matrix by different values in MATLAB (array division)

Lets said I have the matrix M = ones(3); and I want to divide each row by a different number, e.g., C = [1;2;3];. 1 1 1 -divide_by-> 1 1 1 1 1 1 1 -divide_by-> 2 = 0.5 0.5 0.5 1 1 1 -divide_by-> 3 0.3 0.3 0.3 How can I do this without using loops? ...