# How do I put this in a matrix?

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

public void transform(double p[],double x[], double y[], double z[]){
double np[] = new double[3] ;
np[0] = p[0]*x[0]+p[1]*y[0]+p[2]*z[0] ;
np[1] = p[0]*x[1]+p[1]*y[1]+p[2]*z[1] ;
np[2] = p[0]*x[2]+p[1]*y[2]+p[2]*z[2] ;
p = np ;
}


I'm certain that the vectors x,y and z could be used to make a matrix that would perform the same function, but I don't know where to put the variables to make that matrix.

##### Share on other sites
Matrix m:
m[0]=x[0] m[1]=y[0] m[2]=z[0]m[3]=x[1] m[4]=y[1] m[5]=z[1]m[6]=x[2] m[7]=y[2] m[8]=z[2]

Also its a very bad idea to use new inside of a function. In this case just double np[3]; will work as just as well.

##### Share on other sites
Thanks, now I can pipeline this function :)

I wrote this code just for this post and it is in java so I dont think "double np[3] ;" would work

##### Share on other sites
Quote:
 Original post by AlrecenkThanks, now I can pipeline this function :)I wrote this code just for this post and it is in java so I dont think "double np[3] ;" would work

Oh.. Well I don’t know java, I assumed C++, just disregard that then.

##### Share on other sites
What exactly is the problem - im a little confused!

Anyway.. Im a java-programer too and I use the javax.vecmath package. It contains the Matrix4d and Matrix4f classes with lots of constructors for each. Also that same package has a lot of predefined goodies. Take a look...

If you still have problems let me know, but please explain exactly what it is your need!

##### Share on other sites
I think Grain answered my question(though I haven't tested it yet). Those matrix classes don't look like they have that much to offer, and the closest they have to my method is inputting all the variables manually. Actually my planned use for this function is for a game I'm working on in c++. I just wrote in java for testing purposes(The graphics are much more user freindly).

This method converts points from one axis system to another. It is designed to allow viewing through portals. If I create two of these matrices and multiply by the inverse of the current system relative to the portal and then multiply by the matrix created from the other side of the portal I get a matrix that will convert the points outside the other side of the portal to points behind the side of the portal you are looking through. It is also good for making points relative to a view vector. In fact, I'm surprised it isn't used more; I've never managed to find any info on this at all.

Thanks for trying to help, but you should really read the whole thread before posting.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 15
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011521
• ### Who's Online (See full list)

There are no registered users currently online

×