[orx-shapes] Add generated and verified documentation
This commit is contained in:
@@ -5,14 +5,36 @@ import org.openrndr.shape.ShapeContour
|
||||
import org.openrndr.shape.contour
|
||||
|
||||
/**
|
||||
* A circular arc
|
||||
* Represents an arc defined by a center point, a radius, and a range of angles.
|
||||
*
|
||||
* This class provides methods to compute the position of a point along the arc
|
||||
* and to create a shape contour representation of the arc.
|
||||
*
|
||||
* @property center The center point of the arc.
|
||||
* @property radius The radius of the arc.
|
||||
* @property angle0 The starting angle of the arc, in degrees.
|
||||
* @property angle1 The ending angle of the arc, in degrees.
|
||||
*/
|
||||
class Arc(val center: Vector2, val radius: Double, val angle0: Double, val angle1: Double) : LinearType<Arc> {
|
||||
/**
|
||||
* Calculates the position of a point along the arc at a specified parameter `t`.
|
||||
* The parameter `t` interpolates between the starting and ending angles of the arc.
|
||||
*
|
||||
* @param t A parameter ranging from 0.0 to 1.0, where 0.0 corresponds to the starting point of the arc
|
||||
* and 1.0 corresponds to the ending point of the arc.
|
||||
* @return The position of the point on the arc as a [Vector2].
|
||||
*/
|
||||
fun position(t: Double): Vector2 {
|
||||
val angle = mix(angle0, angle1, t.clamp(0.0, 1.0))
|
||||
return Polar(angle, radius).cartesian + center
|
||||
}
|
||||
|
||||
/**
|
||||
* A computed property that provides a [ShapeContour] representation of the arc.
|
||||
* The contour is constructed by moving to the position at the start of the arc (t=0.0),
|
||||
* and then creating a circular arc from that point through an intermediate position
|
||||
* (t=0.5) before ending at the final position (t=1.0).
|
||||
*/
|
||||
val contour: ShapeContour
|
||||
get() {
|
||||
return contour {
|
||||
|
||||
@@ -6,8 +6,13 @@ import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Find intersection of [this] and [other]
|
||||
* @return a rectangle shaped intersection or [Rectangle.EMPTY] when the intersection is empty.
|
||||
* Computes the intersection of the current box with another box.
|
||||
* If the two boxes intersect, the resulting box represents the overlapping region.
|
||||
* If the two boxes do not intersect, an empty box is returned.
|
||||
*
|
||||
* @param other The box to intersect with the current box.
|
||||
* @return A new box representing the overlapping region between the current box and the specified box,
|
||||
* or an empty box if there is no intersection.
|
||||
*/
|
||||
fun Box.intersection(other: Box) : Box = if (this.intersects(other)) {
|
||||
val tn = this.normalized
|
||||
|
||||
@@ -7,6 +7,17 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.LineSegment
|
||||
import org.openrndr.shape.ShapeContour
|
||||
|
||||
/**
|
||||
* Represents a net defined by two points and a circle. The net can be seen as a structure
|
||||
* that connects the two points with the circle in between, forming a string-like shape.
|
||||
*
|
||||
* This class implements basic linear transformations such as scaling and translation
|
||||
* and defines how nets can interact by addition or subtraction.
|
||||
*
|
||||
* @property point0 The starting point of the net.
|
||||
* @property point1 The ending point of the net.
|
||||
* @property circle The circle around which the net is constructed.
|
||||
*/
|
||||
class Net(val point0: Vector2, val point1: Vector2, val circle: Circle) :
|
||||
LinearType<Net> {
|
||||
override fun div(scale: Double) =
|
||||
|
||||
@@ -6,6 +6,17 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.LineSegment
|
||||
import org.openrndr.shape.ShapeContour
|
||||
|
||||
/**
|
||||
* Represents a pulley system defined by two circles.
|
||||
*
|
||||
* This class models a geometric structure where two circles are connected with
|
||||
* tangential lines, forming a pulley-like system. The `Pulley` class provides
|
||||
* operations for scaling, addition, and subtraction, as well as generating
|
||||
* a contour that represents the shape of the pulley.
|
||||
*
|
||||
* @property circle0 The first circle in the pulley system.
|
||||
* @property circle1 The second circle in the pulley system.
|
||||
*/
|
||||
class Pulley(val circle0: Circle, val circle1: Circle) : LinearType<Pulley> {
|
||||
override fun div(scale: Double): Pulley {
|
||||
return Pulley(circle0 / scale, circle1 / scale)
|
||||
|
||||
@@ -5,8 +5,12 @@ import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Find intersection of [this] and [other]
|
||||
* @return a rectangle shaped intersection or [Rectangle.EMPTY] when the intersection is empty.
|
||||
* Computes the intersection of two rectangles and returns the resulting rectangle.
|
||||
* If the rectangles do not intersect, an empty rectangle is returned.
|
||||
*
|
||||
* @param other The rectangle to intersect with the current rectangle.
|
||||
* @return A [Rectangle] representing the overlapping area of the two rectangles,
|
||||
* or an empty rectangle if there is no intersection.
|
||||
*/
|
||||
fun Rectangle.intersection(other: Rectangle) : Rectangle = if (this.intersects(other)) {
|
||||
val tn = this.normalized
|
||||
|
||||
@@ -7,6 +7,17 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.LineSegment
|
||||
import org.openrndr.shape.ShapeContour
|
||||
|
||||
/**
|
||||
* Represents a "Tear" consisting of a point and a circle.
|
||||
*
|
||||
* This class allows operations such as addition, subtraction, scaling, and division,
|
||||
* which are defined element-wise for the point and circle components of the Tear.
|
||||
* Additionally, it provides a computed property that generates a closed shape contour
|
||||
* based on the geometry of the Tear.
|
||||
*
|
||||
* @property point The [Vector2] coordinate representing a point in the Tear.
|
||||
* @property circle The [Circle] geometry associated with the Tear.
|
||||
*/
|
||||
class Tear(val point: Vector2, val circle: Circle) : LinearType<Tear> {
|
||||
override fun div(scale: Double) = Tear(point / scale, circle / scale)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user