Skip to content

Fisheye effect #4

@rostidev

Description

@rostidev

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_t project(point3d_t p) {
    const float focal = 2.5f;  // Focal distance of virtual lens
    return (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:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions