[orx-noise] Add Rseq and Hammersley sequences

This commit is contained in:
Edwin Jakobs
2025-01-24 11:34:49 +01:00
parent c059b11841
commit c7b81feb5e
9 changed files with 397 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package hammersley
import org.openrndr.application
import org.openrndr.extra.noise.hammersley.hammersley2D
/**
* Demo that visualizes a 2D Hammersley point set.
*
* The application is configured to run at 720x720 resolution. The program computes
* 400 2D Hammersley points mapped within the bounds of the application's resolution.
* These points are visualized by rendering circles at their respective positions.
*/
fun main() {
application {
configure {
width = 720
height = 720
}
program {
extend {
val points = (0 until 400).map {
hammersley2D(it, 400) * 720.0
}
drawer.circles(points, 5.0)
}
}
}
}

View File

@@ -0,0 +1,46 @@
package hammersley
import org.openrndr.application
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.hammersley.hammersley3D
import org.openrndr.math.Vector3
/**
* Demo program rendering a 3D visualization of points distributed using the Hammersley sequence in 3D space.
*
* The application is set up at a resolution of 720x720 pixels. Within the visual
* program, a sphere mesh is created and a set of 1400 points is generated using
* the Hammersley sequence. Each point is translated and rendered as a small sphere
* in 3D space. This is achieved by mapping the generated points into a scaled domain.
*
* The rendering utilizes the Orbital extension, enabling an interactive 3D camera
* to navigate the scene. The visualization relies on the draw loop for continuous
* rendering of the points.
*/
fun main() {
application {
configure {
width = 720
height = 720
}
program {
val sphere = sphereMesh(radius = 0.1)
extend(Orbital())
extend {
val points = (0 until 1400).map {
(hammersley3D(it, 1400) - Vector3(0.5)) * 10.0
}
for (point in points) {
drawer.isolated {
drawer.translate(point)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}
}
}
}

View File

@@ -0,0 +1,52 @@
package hammersley
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.hammersley.hammersley4D
import org.openrndr.extra.noise.rsequence.rSeq4D
import org.openrndr.math.Vector4
import kotlin.math.abs
import kotlin.math.min
/**
* Demo that visualizes a 4D Hammersley point set in a 3D space, with colors determined by the 4th dimension.
*
* The application is configured at a resolution of 720x720 pixels. A sphere mesh is created
* using the `sphereMesh` utility, and a total of 10,000 4D points are generated with the
* `hammersley4D` sequence. These points are scaled, translated, and rendered as small spheres.
* The color of each sphere is modified based on the 4th dimension of its corresponding point by
* shifting the hue in HSV color space.
*
* This program employs the `Orbital` extension, enabling camera interaction for 3D navigation
* of the scene. Rendering occurs within the draw loop, providing continuous visualization
* of the point distribution.
*/
fun main() {
application {
configure {
width = 720
height = 720
}
program {
val sphere = sphereMesh(radius = 0.1)
extend(Orbital())
extend {
val points = (0 until 10000).map {
(hammersley4D(it, 10000) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0)
}
for (point in points) {
drawer.isolated {
drawer.translate(point.xyz)
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}
}
}
}