Giter Site home page Giter Site logo

photon's Introduction

photon

Rays and geometries in C for graphics and physics. Various implementations of ray casting and intersections algorithms between different primitives in 2D and 3D.

  • 2D and 3D Ray Casting
  • 2D and 3D Triangle Implementations
  • Basic Shapes and Intersection Algorithms

The complete API can be found in the single header of the library, photon.h.

Example

#include <photon.h>

/* Check if a ray intersects a triangle in 3D */

int main(void)
{
    /* ... */

    Hit3D hit;
    Ray3D ray = ray3D_new(origin, direction);
    Tri3D tri = {p1, p2, p3};

    if (tri2D_hit(&tri, &ray, &hit)) {
        vec3 p = ray3D_at(&ray, hit.t);
        printf("Hit At: %f, %f, %f\n", p.x, p.y, p.z);
        printf("Normal: %f, %f, %f\n", hit.normal.x, hit.normal.y, hit.normal.z);
    } else {
        printf("Ray did not hit triangle\n");
    }
    
    /* ... */
}

Dependencies

The single project on which photon depend is pretty tiny and depends only on the standard C math library, so it can be built easily.

  • fract: Small 2D and 3D math library for games and graphics

Clone

Be sure to clone fract into the repository, otherwise you won't be able to link successfully.

git clone --recursive https://github.com/LogicEu/photon.git

Build

You can compile the library with either of the two build scripts in this repo using make or bash. The compiled library will be placed at /bin

make all -j # or ./build.sh all

There is a simple installation function that builds the library and puts it in the /usr/local directory:

sudo make install # or sudo ./build.sh install

Clean object files and binaries created during compilation in /tmp and /bin with:

make clean # or ./build.sh clean

photon's People

Contributors

logiceu avatar

Watchers

 avatar  avatar

photon's Issues

License?

This is pretty cool ๐Ÿ˜Ž
You don't mention a license in any of your repositories though, so i assume it's just copyrighted?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.