Re: Matrix Inversion

I don't know if I've understood your problem :
Given two matrix A and B we suppose that B verify that is possible obtain a inverse B^-1 that exists C matrix such :
C = A x B^-1
Your question is how can made for obtain C or B^-1 ?

and no, not all encryption relies on Matrix multiplication....its just a common technique...and I really have always been interested in it since I first heard about it in Algebra II
After I finish this project, i'll hopefully have a much better grasp on security and encryption

Similar Messages

  • Cwmatrix inversion VB6

    Hello,
    We are developping an application with matrix using VB6 SP4.
    We use "Component Works 2.0.1" of National Instrument in order to use matrix functions.
    So, in a Form we have added the component CWMatrix (rename CWMatrix1). We use it to make some operations :
    Multiplications : CWMatrix.MatrixMul(x)
    Inversion : CWMatrix.InvMatrix(x)
    We have been able to use without any problem the multiplication function and we get the good results.
    However we can't use correctly the inversion function because whatever is the input matrix, an error message tell us
    that the matrix is singular and can't be reversed, whereas we put an input matrix which can be reversed.
    We have tryed to use the function CWMatrix.Determinant(x) to calculate
    the determinant but whatever is the matrix, the result is always 0.
    We can see a part of our code :
        'Matrix Déclaration in the top of the Form
        Private MatricePassageGlobale() As Double 'Matrice de passage globale
        Private MatricePassage2() As Double 'Matrice de passage
        Private MatricePassage3() As Double 'Matrice de passage
        'Matrix redimensioning
        ReDim MatricePassageGlobale(3, 3)
        ReDim MatricePassage2(3, 3)
        ReDim MatricePassage3(3, 3)
        'Code
          MatricePassage2(1, 1) = 1
          MatricePassage2(2, 2) = 1
          MatricePassage2(3, 3) = 1
          MatricePassage3(1, 1) = 2
          MatricePassage3(2, 2) = 2
          MatricePassage3(3, 3) = 2
          MatricePassageGlobale = CWMatrix1.MatrixMul(MatricePassage2, MatricePassage3)
          'Results checking
          MsgBox "1,1= " & MatricePassageGlobale(1, 1)
          MsgBox "1,2= " & MatricePassageGlobale(1, 2)
          MsgBox "1,3= " & MatricePassageGlobale(1, 3)
          MsgBox "2,1= " & MatricePassageGlobale(2, 1)
          MsgBox "2,2= " & MatricePassageGlobale(2, 2)
          MsgBox "2,3= " & MatricePassageGlobale(2, 3)
          MsgBox "3,1= " & MatricePassageGlobale(3, 1)
          MsgBox "3,2= " & MatricePassageGlobale(3, 2)
          MsgBox "3,3= " & MatricePassageGlobale(3, 3)
          'Determinant display
          MsgBox "det = " & CWMatrix1.Determinant(MatricePassageGlobale)
          'Matrix inversion
          MatricePassageGlobale = CWMatrix1.InvMatrix(MatricePassageGlobale)
    On the line of the inversion, an error message occured :
    Erreur d'exécution '20041'
    The Syteme of equations cannot be solved because the input matrix is singular
    Could you help us to solve this problem please ?
    Thank a lot if you have read our message and if you can answer
    Julien

    Have a look on the following forum:
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=57289&requireLogin=False
    Hope this helps.
    Omar S. NI

  • Honest opinions on SSD drives

    I've read the blog by the Lenovo employee about the drive. I'm looking for comments/opinions about the drive offered by Lenovo from people who don't work for the company. 
    Is the price worth it?
    If I really do want the SSD, is it more worthwhile to buy the cheapest drive from Lenovo and buy an SSD independently? 
    What kind of gains can I expect? Is it worth paying extra for a hard drive and saving on the CPU?
    I saw the article by Tom's hard drive. I assume I should not make this decision with battery power in mind.
    Hard drive space is not an issue. 
    All the work I do is in Matlab and involves lots of monte carlo runs of simple procedures that have to initialize variables and kill them. It involves many matrix inverses and inefficient and poorly written code.  
    Thank you  

    The advantage of a SSD drive is that the battery last a bit longer because it use less power. There are less heat and less noise, no movable parts which is an advantage especially for a laptop that is usually moved around a lot.
    And of course it's faster which is true especially for reading. The SSD is much faster for reading operations then writing operations. The disadvantage is the price and size, but if the size is no issue then i guess the price is the only drawback.
    If you decide to buy the SSD separate from somewhere else make sure it's a SLC and not a MLC. SLC is much faster and usually very expensive compared to the MLC. You can read more about SLC/MLC if you google for something like "SSD SLC MLC".
    For me i don't think it's worth the cost since i need more space then the SSD can offer and find the price to be a bit to high. If i could get at least a 250gb SSD for a reasonable price then i would consider to buy one even if the price is pretty much higher then a HD. If size is no issue and you don't think the price is way to high then i would recommend to buy a SSD. But don't expect miracles since i didn't find the difference to be huge using a SSD compared to a 7200rpm harddrive.
    Message Edited by gan on 03-09-2009 08:30 PM

  • (Why) do we still need primatives?

    I think the answer, sadly, is that we do, if only for things like array indexing and tracking looping iterations, not to mention conformity with existing API. What else?
    There are at least 2 reasons to get rid of primatives, as I see it:
    1. Using primitives you must make a compile time decision about what range of values and how much accuracy (rounding errors & such) those using your code in the future will need. By abstracting with with BigInteger and BigDecimal you don't have to limit yourself.
    2. primitives and primitive arrays are such a special case, since they are not objects (ok, a primitive array is an object, but with no methods)
    Thoughts?

    puckstopper31 wrote:
    sabre150 wrote:
    I'm always surprised when people think we can get rid of primitives. Just try writing a high performance matrix inversion or FFT or other mathematically intensive algorithm without them. If Java had no primitive 'int' and 'double' I would have to go back to using C++ and I would hate that.
    Rather than get rid of primitives I would like to add to them. I would like double complex, float complex, unsigned int, unsigned long and unsigned byte but the mere suggestion of including these in the Java language puts some people into apoplexy. They start crossing themselves and they tell me to wash my mouth out with soap in much the same way as when I suggest adding operator overloading.
    In a few years when computers are 100 times as fast and have 100 times as much memory then I might consider doing without primitives but not yet.and yet you claim to hate C++ but that is (very nearly) what you would be turning Java into. Inconsistency is a sure sign of insanity.
    Kidding just kidding.Although you are kidding it does have some truth. C++ is a great language and I made a living out of it for years. For some reason, some people seem to think that C++ can be an alternative to Java for those people who want to change Java. This is not the case. When I first used C++ it was so much better than C and FORTRAN but the limitations and the complexity it exhibited made people ask for changes. Some of the purists resisted the changes arguing that C++ was designed that way and that if you didn't like some of the features then you should go back to C or FORTRAN or PL/M . The argument does not seem to have changed - just the base Language. Languages evolve as people get experience of using them and find the warts that they exhibit. These warts need to be removed and the only question seems to be which warts are necessary and which would just be nice to remove. Some C++ warts were removed but the removal sometimes adds more problems (C++ templates are a prime example but I would not get rid of them). Java is an advance on C++ but should not be static.
    Java has evolved since I first met it as 1.02 and for the most part I like the new evolved features. I still have reservations about the need for 'closures' but just because I don't see the need does not mean that there is no need for them. I just don't use them but maybe I will when I understand the best place to use them. I don't want Java to be static and not evolve because though Java is a good language and has brilliant libraries it is not perfect.
    I find it really weird that the youngsters here seem to be the conservatives and I, probably being the oldest regular contributor to these forums, am the revolutionary.

  • Read multiple axis status

    The problem is the slowness of some commands in Labview 8.2 (winxp and PXI-8105 controller)
    I am trying to control the speed of a three axis robot  using a PXI-7350 motion controller, but I need to update very fastly the control loop (1-2ms)
    I found that the more time consuming functions are "read per axis status" and "load velocity".
    These are probably the main issues to be considered
    1. I need only to read the "motor off", "following error", "Move Complete" while the "read per axis status"returns many other variables.
    2.  Both the vi must be called three times, one time for each axis.
    Is it possible to build a single vi that, using a single command, queries the motion controller only for few specified variables and sets all the axis velocities?
    In case, the variables are:
     "motor off"
     "following error"
    "Move Complete"
    "vector space position"
    Thanks

    The application is: to move the end effector as a function of an
    analog feedback signal, avoiding auto-collision (like moving a robot
    with a joystick).
    The problem is that the signal is correlated to
    the motor displacements via a unlinear process so the control board
    cannot be configured using that signal. I have to measure the signal
    and to calculate on the fly the velocities of the motor that make the
    end effector follows the feedback signal. I need to optimize the
    "control loop" in order to avoid vibrations, jitter and to permit the
    PXI to make other things like data communication with other pc in the
    network. Another important issue is the critical routine for
    auto-collision avoiding: the robot must stop as soon as particular
    combination of axes position occurs.
    It's incredible, I
    spent so much time in optimizing the kinematic calculations (a 9x9
    non-linear sistem of equations solved in 2ms) and now I see that the
    critical routine is the communication between PXI-controller and motion
    controller!!!
    (I know that the best solution would be to
    build a motion controller by myself using a NI-FPGA device, but I
    really don't know how to implement a matrix inversion calculation on a
    FPGA processor...)
     Fabrizio Patanè

  • Constrained Nonlinear Optimization

    Hello,
    I have some trouble using the  "Constrained Nonlinear Optimization.vi"
    Apart from the manual I could not find much information on the algorithm on the internet... It look like often my program gets stuck in a loop inside the subvi "isisubopt.vi" (L-->inf , matrix inversion results in a matrix of zeros). This happens with some datasets, not with others, but when it gets stuck, there is no possibility to leave the loop and thus I have to quit the vi.
    Is there reason for this eternal loop, and it there any way to avoid this situation?
    Thanks, Dirk 

    Hi Dirk,
    I'm not familiar with the algorithm, but the Wikipedia page is likely a good start point. There's a PDF at the bottom called "Introduction to Sequential Programming".
    What is the difference in your data sets? Same size?
    Jeff | LabVIEW Software Engineer

  • Discrete state-space representation in FPGA

    Hello all,
    My aim is to simulate a discrete state-space model is the cRIO FPGA (in order to use an observer).
    I am currently trying to simulate it on my computer without using the discrete state-space VI from the Control Design and Simulation toolbox (because there is not state-space model VI for the FPGA). However my discrete state-space model representation does not work.
    There is below the continuous state-space model:
    Then I obtained the discretized model (using the zero-order-hold and t=0.01s):
    Below is the discretized state-space model I designed (in order to design a similar model in the FPGA):
    Here is the discrete state-space VI I'm using to compare the results:
    The graph plots the state X1, which is infinitely increasing. However it should look like a first order, as you can see:
    I understand why the state X1 is increasing like this, I know I'm missing something (integration saturation ?).
    Thanks in advance
    Regards!
    PS: Does somebody know if implenting other controller than the PID is doable in the cRIO FPGA? I also asking myself about matrix inversion if I want to use the Kalman gain in my observer.
    PS2: I apologize for my disorganized/unclear Labview files, I'm beginning with it.
    Solved!
    Go to Solution.
    Attachments:
    SS Discret Simulation.vi ‏544 KB
    SS Discret Model.vi ‏21 KB

    Hi,
    I think the problem might be caused by rounding errors in your A and B matrices.  Have you tried getting it to display the values with greater precision?
    Matlab calculates those values as:  A = [0.995, 0.009925; 0 0.99],  B = [2.488e-5; 0.004975]
    Regards,
    Ian

  • New ICC standard?

    So while stumbling around the Internet this morning in a caffeine-deprived stupor, I found some talk about a new gamma curve for an upcoming revision of color management policies. It read, in part:
    To complicate the matters, L* curve will become an official recommendation for ECI RGB V2...To complicate the matters yet further, 1976 CIE L*a*b* colorspace is not perceptually uniform in areas of high chromaticity, and also the original 1976 L* curve was ill-defined mathematically (it had noncontinuity in shadow areas leading to problems in matrix inversions). This lead to the replacement of traditional CIE L*a*b* delta-E used in evaluation of profiles with CIE DE-2000.
    The upshot of all this is, I followed links to these two pages:
    http://www.swop.org/
    http://www.colormanagement.org/en/swopprofile.html
    Of particular interest to me are the SWOP profiles in the second link. Are they of any value or should I avoid them like the plague? Your opinions and comments are welcome. :)
    EDIT: oh yeah, a new Lab profile was thrown into the mix as well...
    http://www.brucelindbloom.com/UPLab.html

    Correct me if I am wrong, but I believe that the L* gamma curve is only for monitor calibration and has nothing to do with delta-E calculations in CIE L*a*b*. It also has nothing to do with the new SWOP data sets that your links refer to. The profiles you link to are high GCR profiles made from the same data as the "official" profiles available through IDEAlliance: http://www.idealliance.org/swop/resources/
    Both the IDEAlliance and colormanagement.org profiles are perfectly valid if you are printing to those conditions. The data sets describe averaged web-offset print conditions on #3 and #5 coated sheets respectively, and can be used without fear! There is also the GRACoL_Coated1 data set and profiles, which describes sheetfed printing on a #1 coated sheet, which may also be appropriate, depending on how you are printing.
    I don't know much about Bruce Lindbloom's "Universal Perceptual Lab" profile, but once again, I don't think this has any bearing on SWOP datasets or profiles.
    -Todd Shirley

  • Read Inbound Email status ?

    HI Expert ,
    I want to get/read the inbound email status from table or FM . Suppose i have read email then where it status saved .
    a. I have received email and check sood and soos table
    b. now i have read the email
    c. How to get the status of email "Read" or not ?
    please...please help...
    Thanks ,
    rishi

    The application is: to move the end effector as a function of an
    analog feedback signal, avoiding auto-collision (like moving a robot
    with a joystick).
    The problem is that the signal is correlated to
    the motor displacements via a unlinear process so the control board
    cannot be configured using that signal. I have to measure the signal
    and to calculate on the fly the velocities of the motor that make the
    end effector follows the feedback signal. I need to optimize the
    "control loop" in order to avoid vibrations, jitter and to permit the
    PXI to make other things like data communication with other pc in the
    network. Another important issue is the critical routine for
    auto-collision avoiding: the robot must stop as soon as particular
    combination of axes position occurs.
    It's incredible, I
    spent so much time in optimizing the kinematic calculations (a 9x9
    non-linear sistem of equations solved in 2ms) and now I see that the
    critical routine is the communication between PXI-controller and motion
    controller!!!
    (I know that the best solution would be to
    build a motion controller by myself using a NI-FPGA device, but I
    really don't know how to implement a matrix inversion calculation on a
    FPGA processor...)
     Fabrizio Patanè

  • Calculate symmetrica​l components of voltage and current

    Hi, all. i am working on the calculation of symmetrical components of voltage and current in Labview. I have attached the relationship between symmetrical component and sequence voltage as picture 1. I will use this calculation for several times, so I wonder if anyone have some better ideas bc so far I just wired so many things together to realize the expression. It looks aweful. Any suggestion? such as built-in function to realize this function? thanks   
    Solved!
    Go to Solution.
    Attachments:
    pic1.jpg ‏21 KB

    Let's look at your formula (you don't say what's complex, etc., so modify as needed)
    For example here's how you would create the A matrix from a given alpha.
    Similarly, you can create the A^(-1) matrix (your definition of A and A^(-1) seem inconsistent, else you could just take the matrix inverse of A). After that, you can multiply with you V123 vector using AxB.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AlphaToA.png ‏7 KB

  • Lev-Mar does fit but says I have a singularit​y?

    My Levenberg-Marquardt fit seems to work OK on this data set, and yet I still see the following error when I run the program:
    "The system of equations cannot be solved because the input matrix is singular."
    Also, the VI says my mean-squared error is on the order of 10^6.
    What am I doing wrong?
    -Stefano
    Attachments:
    VApprox.llb ‏223 KB
    1-9760.txt ‏9 KB

    Your model only uses four parameters, but you feed it 8 parameters. (resize the "initial guess" control to see)!
    You need to make sure that it only contains 4 elements. Just hiding them by making the array container smaller does not help .
    Basically what happens. The fit proceeds fine, because the unused parameters always have a zero partial derivative and they are considered converged from the beginning. The only problem is the matrix inversion for the covariance matrix output. It cannot be inverted because it contains multiple rows and columns with zeroes
    Also make sure to NOT use "insert into array" to programmatically modify an initial estimate. Use "replace array element" else you change the number of parameters again.
    The attached seems to work just fine. See if it helps.
    Message Edited by altenbach on 01-05-2006 09:11 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    VApproxMOD.llb ‏208 KB

  • Need TCP Error Explanation

    One thread is doing hairy math problems (500x500 CDB matrix inversions and stuff), and posting results into a queue. After it posts results, it proceeds with the next math problem.
    Another thread picks up the results from the queue, opens a TCP connection to another thread (on the same machine or a different machine), and transmits the results, after converting them to a string.
    The results might be 50-100 kBytes.
    The transmit thread opens a connection, transmits a header and a block(of 1024), a header and a block, a header and a block, etc. until done.
    The receive thread waits on a connection, then receives a header (fixed size), then a block (described by the header), a header and a block, a header and a block, etc., until done.
    All TCP operations use a timeout of 200 mSec.
    The trouble is, I�m getting receiver errors (56 = timeout), that the transmit side doesn�t see. The transmit side is set to detect an error, and re-do the whole thing later if an error occurs. That has previously proven to be working. But now, I have cases where the receive side reports an error (56), but the transmit side doesn�t know about it, so my code fails.
    I thought that an error on the receive side would be reflected back to the transmit side. (guaranteed delivery?)
    Should I jack up the timeout value and hope for the best?
    Should I implement an acknowledge reply scheme?
    Other ideas?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    The transmitter: transmits a header and a block, wait for feedback, transmits a header and a block, wait for feedback, and so on...
    The receiver waits on a connection, then receives a header, then a block, then send feedback, and so on...
    I really don't want to do it that way. I thought the job of the TCP / IP layer was to handle this feedback. For the most part, the data moves really fast - 10 mSec or less for the whole thing. I don't want to bog that down with a handshake on every block. I suspect that it's being delivered from OS to OS, but the problem is getting it into LabVIEW. That would explain why there's no error showing up on the transmit side.
    I'm thinking of implementing an overall feedback - if I received the whole 50
    k-100k bytes successfully, I'll send a feedback packet down the same connection. If the transmitter doesn't get the feedback within X mSec after sending the last packet, it will put it back into the queue for re-transmission.
    In my case it's not important to get it there soon, but important to know that it gets there.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Inverse of Matrix problem

    Hello.
    I have a inverse matrix task.Teacher said us that we have to create little a program which is finds inverse of the matrix which is given in code.
    I did something like this and when I gave him this task he said me that "I want the program calculate itself matrix size.You wont give size of matrix like int[4][4]; this.You just will write the matrix in your code and the program will change as depend to size and calculate automatically as the matrix."
    I some more explain for all of you understand more.
    Example I write in code
    3x3 a matrix okay.Below an example.
    3 4 6
    1 5 7
    1 3 7
    This is 3x3 matrix so its calculating.And I want now 4x4 matrix.
    4 5 1 6
    1 4 5 6
    2 4 5 5
    1 2 4 7
    Also this matrix will calculate as automatically depend to matrix size.
    I musnt write [4][4] or [3][3].Instead this I need to write something like will change as matrix size automatically.I hope you understand.Because Im really bored with this.Its just second month in programming for us and I have no idea about this task anymore.
    import java.util.Scanner;
    public class inversematrix {
    public static void main(String[] args)
    int[][] matrix = new int[4][4];
    Scanner inputUser = new Scanner(System.in);
    System.out.println("Write matrix number");
    for(int row=0; row<4; row++)
    for(int column=0; column<4; column++)
    System.out.print("A"+(row+1)+(column+1)+" = ");
    matrix[row][column] = inputUser.nextInt();
    System.out.println("4 na 4 matris");
    for(int row=0; row<3; row++)
    for(int column=0; column<3; column++)
    System.out.printf("%3d",matrix[row][column]);
    System.out.print("\n");
    System.out.println("Inverse of matrix calculating");
    int matrixInvers[][] = {{matrix[1][1]*matrix[2][2]-matrix[1][2]*matrix[2][1],matrix[0][2]*matrix[2][1]-matrix[0][1]*matrix[2][2],matrix[0][1]*matrix[1][2]-matrix[0][2]*matrix[1][1]},
    {matrix[1][2]*matrix[2][0]-matrix[1][0]*matrix[2][2],matrix[0][0]*matrix[2][2]-matrix[0][2]*matrix[2][0],matrix[0][2]*matrix[1][0]-matrix[0][0]*matrix[1][2]},
    {matrix[1][0]*matrix[2][1]-matrix[1][1]*matrix[2][0],matrix[0][2]*matrix[2][0]-matrix[0][0]*matrix[2][1],matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0]}};
    System.out.println("Inverse matrix");
    for(int row=0; row<3; row++)
    for(int column=0; column<3; column++)
    System.out.printf("%3d",matrixInvers[row][column]);
    System.out.print("\n");
    Edited by: 1004884 on 08.May.2013 14:27

    Come on man so what should I ask here?First of all, your question has nothing, nada, zilch, zero, or in Java terms
    final const int amount_of_relevance_of_your_question_to_this_forum = 0;to do with the topic of this forum, which is the JDeveloper IDE and the Oracle Application Development Framework (ADF)
    You're asking general Java questions, in which case there are plenty of general Java forums out there (including on this site). If I were taking a course and was stumped, I'd either:
    * ask the teacher or teaching assistant for help
    * talk to one of my classmates

  • Inverse Matrix

    Hi can anyone advise me on how to create an inverse matrix on a 2D array?
    This is how i created my 2D array(2x2 matrix):
    Use the build array function to append
    the first 2 arrays into a longer 1D array, then do the same with the other
    2, then use the build array function again in its default manner to stack
    the 2 longer 1D matices on top of each other.
    My problem is how to extract out every square martix set  in each iteration to do an inverse?

    OK, this seems trivial then
    You form the 2x2 matrix from the i'th elements of the four input vectors X,Y,Z,W and multiply the inverse with vector B. Each answer is a 1d array, thus giving you a 2D array that contains all results from i=1..n. You don't need any shift registers!
    See attached (LabVIEW 7.0).
    Message Edited by altenbach on 08-09-2005 09:21 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    inverse_matrixMOD.vi ‏37 KB

  • VertexShader - Parameter / Matrix Issues

    I'm trying to implement a simple mask-shader for my 2D engine and I'm having multiple issues getting it to work.
    Basically the shader takes two images and two matrices and tries to map back the vertex position of the sprites vertex back to the local mask space position and then calculate the local uv-coordinates for the mask, but I'm stuck with some basic calculations here.
    Bug 1: Divisions in the material-vertex kernel don't work at all. That's why I have to put invertedMaskSize (which is 1.0 / 128.0) into the shader (but we already know that )
    Bug 2: interpolated vars have to be float4, float2 is not possible (That's a pretty old bug as well)
    I tried the following changes in the shader. The shader posted here, just tries to display the resulting uv-coordinates. No textures are used.
    Case 1:
    interpolatedMaskUV = float4((vertexPos.x + halfMaskSize.x) * invertedMaskSize.x, (vertexPoss.y + halfMaskSize.y) * invertedMaskSize.y, 0.0, 0.0);
    The output is this: http://dev.nulldesign.de/plain_uvcoords.png Just like you expect! Perfect, let's proceed.
    Case 2:
    Change the halfMaskSize and invertedMaskSize to float2 and set set the parameters as two vectors of length two of course in AS. The output: http://dev.nulldesign.de/float2_uvcoords.png
    Case 3:
    Masking Test, matrix multiplication. First calculating the world space position of the vertex:
    float4 worldSpacePos = float4(vertexPos.x, vertexPos.y, 0.0, 1.0) * objectToClipSpaceTransform;
    Then mapping it back to the local space of the mask:
    float4 localMaskSpacePos = worldSpacePos * maskObjectToClipSpaceTransform;
    And calculating the uv-coords:
    interpolatedMaskUV = float4((localMaskSpacePos.x + halfMaskSize.x) * invertedMaskSize.x, (localMaskSpacePos.y + halfMaskSize.y) * invertedMaskSize.y, 0.0, 0.0);
    For testing, I set the maskObjectToClipSpaceTransform to the inverse of the objectToClipSpaceTransform. In theory and on paper, this should work.
    But, I think, something gets out of order and maybe the maskObjectToClipSpaceTransform is screwed up in the shader, just like when I set the halfMaskSize and invertedMaskSize to float2. The result is this: http://dev.nulldesign.de/local_uvcoords.png and I have no idea how to fix this...
    <languageVersion : 1.0;>
    material kernel texture
    <
        namespace : "ND2D_Shader";
        vendor : "nulldesign";
        version : 1;
    >
        input vertex float2 uvCoord
        <
            id : "PB3D_UV";
        >;
        input vertex float2 vertexPos
        <
            id : "PB3D_POSITION";
        >;
        parameter float2 uvOffset;
        parameter float4x4 objectToClipSpaceTransform;
        parameter float4x4 maskObjectToClipSpaceTransform;
        // if set to float2, strange things happen
        parameter float4 halfMaskSize;
        parameter float4 invertedMaskSize;
        interpolated float4 interpolatedUV;
        interpolated float4 interpolatedMaskUV;
        void evaluateVertex()
            // not used in the current test ...
            interpolatedUV = float4(uvCoord.x + uvOffset.x, uvCoord.y + uvOffset.y, 0.0, 0.0);
            float4 worldSpacePos = float4(vertexPos.x, vertexPos.y, 0.0, 1.0) * objectToClipSpaceTransform;
            // doesn't work as expected
            float4 localMaskSpacePos = worldSpacePos * maskObjectToClipSpaceTransform;
            interpolatedMaskUV = float4((localMaskSpacePos.x + halfMaskSize.x) * invertedMaskSize.x,
                                        (localMaskSpacePos.y + halfMaskSize.y) * invertedMaskSize.y,
                                         0.0, 0.0);
        input image4 textureImage;
        input image4 textureMaskImage;
        parameter float4 color;
        output float4 result;
        void evaluateFragment()
              // just visualize the uv-coords
              result = float4(interpolatedMaskUV.x, interpolatedMaskUV.y, 0.0, 1.0);
            float4 texel = sample(textureImage, float2(interpolatedUV.x, interpolatedUV.y), PB3D_2D | PB3D_MIPNEAREST | PB3D_CLAMP);
            float4 texel2 = sample(textureMaskImage, float2(interpolatedMaskUV.x, interpolatedMaskUV.y), PB3D_2D | PB3D_MIPNEAREST | PB3D_CLAMP);
            result = float4(texel.r * color.r,
                            texel.g * color.g,
                            texel.b * color.b,
                            texel.a * color.a * texel2.a);
    I know that we're working with a four month old version of pb3d and I hope that a new version will be out soon and maybe all these bugs I encountered are already solved, but if not.... here's another shader to fix

    Ah that's interesting. I thought after compiling the three shaders with pixelbender, the two vertex kernels are merged and I can use the same parameters. This would mean, I have to push objectToClipSpaceTransform twice (with a different name)? So I would to waste four registers
    Here is the AGAL version of the shader, it's working as expected:
    vertex:
    m44 vt0, va0, vc0                   // vertex * clipspace
    m44 vt1, vt0, vc4                   // clipsace to local pos in mask
    add vt1.xy, vt1.xy, vc8.xy     // add half masksize to local pos
    div vt1.xy, vt1.xy, vc8.zw     // local pos / masksize
    mov v0, va1                         // copy uv
    mov v1, vt1                         // copy mask uv
    mov op, vt0                         // output position
    fragment:
    mov ft0, v0                                                   // get interpolated uv coords
    tex ft1, ft0, fs0 <2d,clamp,linear,nomip>      // sample texture
    mul ft1, ft1, fc0                                             // mult with color
    mov ft2, v1                                                   // get interpolated uv coords for mask
    tex ft3, ft2, fs1 <2d,clamp,linear,nomip>      // sample mask
    mul ft1, ft1, ft3                                             // mult mask color with tex color
    mov oc, ft1                                                   // output color
    The full source code here: https://github.com/nulldesign/nd2d/blob/master/src/de/nulldesign/nd2d/materials/Sprite2DMa skMaterial.as
    I'll try it with a different parameter name now. Thanks

Maybe you are looking for

  • Sound Blaster Live CT4620 and Windows XP can it work and h

    Hello, I have an old Sound Blaster Li've Model CT4620 that I installed on my old PC (windows 95) and loved quite a while back, I have since upgraded my Pc to a newer model that has Windows XP Pro and was hoping to install my old much loved Sound Blas

  • Can I use an external monitor/clamshell mode PERMANTENTLY?

    What I'm trying to do is take my old TiBook 550 with its malfunctioning screen and busted hinges (grrrr) and effectively turn it into a low-budget version of a Mac Mini i.e. hook up a USB keyboard and LCD monitor to it and use it as if it were a desk

  • Switching from pc to mac mini

    im thinking of changng my pc to a mac mini to take up less space plus im sick of the noise from pc. it is a quadcore 2.5 with a 1gb graphics card. wat would be the best mini to go for im not really worried about performance or games anymore grown out

  • Transfer HU from consignment to own stock

    Hi, I am trying to post a goods movement using VLMOVE, to transfer a HU in vendor consignment to own stock. Vlmove contains a field special stock, but is disabled? Any ideas? Ravi

  • How can I center text?

    Maybe this question has been asked before, but I have been trying to center a line of text with spaces, and am nearly about to pull my hair out. Is there any way to center a line of text?