Sign in to follow this  
DarkThrone

need help

Recommended Posts

I created a simple library to build 3d objects using the following struct to handle coordinates struct Point{ double x; double y; double z; } and a new struct to hold all shapes struct Shape { struct Point startpoint; struct Point angle; struct Point **holdpoints; unsigned int numberofslices; unsigned int numberofstacks; } so I can use some methods to detect colision, etc... I created a method to update values of **holdpoints to translate it, but I can't create a rotate method, please help me if you need, the help will be apreciatted.

Share this post


Link to post
Share on other sites
Rotation is usually done with rotation matrices or with quaternions.
For 3d rotation you will need 3x3 matrix. More info about rotation matrices is here.
To rotate given vertex simly transform (multiply) it with your matrix. To rotate whole object just transfrom all points.

If you want to do rotation and translation in one matrix, you will need 4x4 matrix. You can find much more about matrices and quaternions in Matrix and Quaternion FAQ.

Share this post


Link to post
Share on other sites
Thanks for the help on references, but if any can, I like some piece of code to help me understand all theory ( It's too much to read and understand further no examples, and the scholar in Brazil is not a "Kind of perfection", hehe...)

The Translate Method for the Library it's as follows:

(Pseudo coding)

void Translate(Shape *sh,double x,double y,double z)
{
sh->startposition = { x,y,z }
for(a=0; a <= sh->numberofstacks; a++)
{
for(b=0;b <= sh->numberofslices; b++)
{
sh->holdpoints[a][b] = {holdpoints[a][b].x + x,...}
}
}
}

if any can give me just a little code to create a rotate method only to figure what happens, will be a big help to me.

This the only piece to continue the library, all other functions are ready and well.

note: help if anyone can learn me how to apply the 3x3 matrix in a cube of 27x14x9 coordinates, for example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this