I need a formula that allows me to rotate a 3d object around a point, I’m creating a 3d renderer using a “Weak Perspective Projection” method to project the points onto a 2d screen, I create these objects using functions like newCube(x,y,z,size) and added them to an array of objects
heres the function i use for putting the points into the object:
function newCube(x, y, z, size,fill){
object = {points:[[x-size,y-size,z-size],[x-size,y-size,z+size],
[x+size,y-size,z-size],[x-size,y+size,z-size],
[x-size,y+size,z+size],[x+size,y-size,z+size],
[x+size,y+size,z-size],[x+size,y+size,z+size]],
vertices:[[0,1],[0,2],[0,3],
[2,5],[3,6],[3,4],
[4,7],[6,7],[7,5],
[5,1],[4,1],[2,6],
],
rot:[0,0,0],
origin:[x,y,z],
type:"cube"
fill:fill
};
objects.push(object);
}
I am using a for loop for every point in the object, should I be doing this or not?“