# need help

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

## 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 on other sites
Rotation is usually done with rotation matrices or with quaternions.
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 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] = {holdpoints[a].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.

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632952
• Total Posts
3009438
• ### Who's Online (See full list)

There are no registered users currently online

×