Jump to content
  • Advertisement
Sign in to follow this  
Alrecenk

How do I put this in a matrix?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Alrecenk
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


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

Share this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!