README.md

vecspace

A library of generic Euclidean functions in 3D space

orthogonal thingybob

This is a work-in-progess at the moment. It's essentially part of my R "hello world" program, so be gentle with me!

I'm learning to build data structures and packages in R. To do this, I'm chucking a slightly ridiculous project at it - which is to revisit my final year Uni project from many, many years ago, and write a functional ray tracing program.

For this project, it feels like there are two different bits of functionality:

[1] This part, which is the maths around the generic work in Euclidean space. Defining elementary and compound objects in space, calculating intersections and so on; and

[2] The actual ray tracing part, which'll cover the camera modelling, surface properties, lighting, and all the recursive shinanegins around that. That'll be a separate package.

Components of vecspace

The hierarchical world

Everything in my world is (currently) made of triangles, spheres, and planes.

I've also included a simple compound object (the cuboid) which will hopefully demonstrate how this stuff works.

A cuboid is a rectangular generalisation of a cube, which is made of six rectangular faces. In my world, a rectangular face can be constructed by adding 2 abutting triangles. The collection of the six faces can be grouped into a list, and common properties applied to either the cube as a whole, each individual face, or (if you really want to) each individual triangle.

Finally, a "bounding volume" can be constructed around the cuboid, which in my world in a sphere which fully encloses all of the components of the cube. It's therefore a hierarchical tree of objects, which can be scanned by a lightray (i.e. to test for intersection) by testing first against the bounding sphere, and then only if it intersects that do we need to test for intersection with each elementary component.

Also, transformation methods (OOP, remember) can be build for each elementary and compound object, such that you can simply say (e.g.) "rotate my cube" and it'll run through the hierarchy of objects and rotate them all in the same geometry by parsing the object hierarchy.

Further general constructors will allow you to, say, build a table from 5 simple cuboid objects, and then be able to simply say "rotate my table" in a single statement. (And or course, the table itself can have a bounding sphere container)

table

Ray tracing

So the main reason for building this package is to facilitate ray tracing. You'll have to have a look at my raytrace package to get the code for that. That's still very much a work in progress, but it's for the most part proven the design of this package. The way this package hasn't needed to care about how surface properties are defined has proved most useful.

Here's a quick demo image from the ray tracing package as it stands. I still need to add in shadowing, transparency and a heap of stuff like that, but it's definitely coming along nicely now....

screen shot 2018-04-04 at 19 57 56



JerBoon/vecspace documentation built on May 26, 2019, 7:28 a.m.