Package raymarcher.meshes
Class Torus
java.lang.Object
raymarcher.meshes.Torus
- All Implemented Interfaces:
Mesh
public class Torus extends java.lang.Object implements Mesh
An implementation of the Mesh interface that renders a torus
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description java.awt.ColorgetMeshColor()Gives the mesh's colorVector3getPosition()doublegetRadius()doublegetThickness()doublesdf(Vector3 position)The signed distance function for the mesh, which tells the mesh's distance to a point in 3D spacevoidsetMeshColor(java.awt.Color meshColor)voidsetPosition(Vector3 position)voidsetRadius(double radius)voidsetThickness(double thickness)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
position
The position of the mesh's center -
radius
private double radiusThe size of the outer radius of the torus -
thickness
private double thicknessThe thickness of the torus -
meshColor
private java.awt.Color meshColorThe color of the mesh
-
-
Constructor Details
-
Torus
Create a torus mesh- Parameters:
position- The position in 3D space to center the torusradius- The outer radius of the torusthickness- The thickness of the torusmeshColor- The color of the torus
-
-
Method Details
-
getPosition
- Returns:
- the current position of the center of the torus
-
setPosition
- Parameters:
position- the new center of the torus
-
getRadius
public double getRadius()- Returns:
- the torus' current outer radius
-
setRadius
public void setRadius(double radius)- Parameters:
radius- the new outer radius for the torus
-
getThickness
public double getThickness()- Returns:
- the torus' current thickness
-
setThickness
public void setThickness(double thickness)- Parameters:
thickness- the new thickness for the torus
-
setMeshColor
public void setMeshColor(java.awt.Color meshColor)- Parameters:
meshColor- The new color to set the mesh to
-
getMeshColor
public java.awt.Color getMeshColor()Description copied from interface:MeshGives the mesh's color- Specified by:
getMeshColorin interfaceMesh- Returns:
- The color of the mesh
-
sdf
Description copied from interface:MeshThe signed distance function for the mesh, which tells the mesh's distance to a point in 3D space- Specified by:
sdfin interfaceMesh- Parameters:
position- The vector representation of the position of the point to measure the distance to- Returns:
- The signed distance of the mesh to the point. Values > 0 indicate the point is outside the mesh, values = 0 are points on the surface, and values < 0 are points inside the mesh.
-