Get the latest tech news

Ray Tracing in J


I've been reading up on J and decided another small project was in order, this time I've written a minimal ray tracer. J is, perhaps infamously, a terse language.

In order to map the range into the RGB space I'm doing max(0, min(floor(x * 255), 255)).&("bond") is used to partially apply arguments to a verb, a simple example would be to define "addOne" as+&1. It'll be responsible for sizing an area to "draw" onto, along with a small bit of math to orient the "eye" to the scene and define our light source and material: I've written a very similar ray tracer in Common Lisp(which I won't claim to be any good at, but certainly have at least as much experience in) and without optimizing anything in either implementation J is performing around 5 times as fast.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Ray tracing

Ray tracing

Related news:

News photo

Creating Doom: The Dark Ages - ray tracing, load times and optimisation in id Tech 8

News photo

Ray Tracing in One Weekend

News photo

Indiana Jones and the Great Circle first update adds full ray tracing on PC