I think the formula is incomplete. How I know this? I've ported your demonstration code to C with SDL3 library and made it showing more than one object. In my case there is one penguin and eight cubes - all rotating together. I've also made it rotating round both xz and yz. With more objects the fisheye effect could be seen better.
To workaround the fisheye effect I added a focal distance factor:
point_tproject(point3d_tp) {
constfloatfocal=2.5f; // Focal distance of virtual lensreturn (point_t){
x: (p.x / p.z) *focal,
y: (p.y / p.z) *focal
};
}You can find the whole code of this port in my GitHub: https://github.com/rostidev/formula
It looks like this:

I think the formula is incomplete. How I know this? I've ported your demonstration code to C with SDL3 library and made it showing more than one object. In my case there is one penguin and eight cubes - all rotating together. I've also made it rotating round both xz and yz. With more objects the fisheye effect could be seen better.
To workaround the fisheye effect I added a focal distance factor:
You can find the whole code of this port in my GitHub: https://github.com/rostidev/formula
It looks like this: