[orx-kdtree] Add generated and verified documentation
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
package org.openrndr.extra.kdtree
|
||||
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.IntVector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.Vector4
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
/** built-in mapper for [Vector2] */
|
||||
|
||||
/**
|
||||
* Maps a 2D vector's dimension to its corresponding value.
|
||||
*
|
||||
* @param v The 2D vector whose dimension is to be mapped.
|
||||
* @param dimension The dimension index to map (0 for x, any other value for y).
|
||||
* @return The value of the specified dimension of the vector.
|
||||
*/
|
||||
fun vector2Mapper(v: Vector2, dimension: Int): Double {
|
||||
return when (dimension) {
|
||||
0 -> v.x
|
||||
@@ -13,6 +21,13 @@ fun vector2Mapper(v: Vector2, dimension: Int): Double {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified dimension of an IntVector2 to a Double.
|
||||
*
|
||||
* @param v the IntVector2 instance containing integer components x and y.
|
||||
* @param dimension the dimension to map (0 for x, any other value for y).
|
||||
* @return the x or y component of the vector as a Double, depending on the specified dimension.
|
||||
*/
|
||||
fun intVector2Mapper(v: IntVector2, dimension: Int): Double {
|
||||
return when (dimension) {
|
||||
0 -> v.x.toDouble()
|
||||
@@ -20,8 +35,13 @@ fun intVector2Mapper(v: IntVector2, dimension: Int): Double {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** built-in mapper for [Vector3] */
|
||||
/**
|
||||
* Maps a Vector3 object to one of its components (x, y, or z) based on the specified dimension.
|
||||
*
|
||||
* @param v the Vector3 object whose component is to be retrieved
|
||||
* @param dimension the index representing the component to be retrieved (0 for x, 1 for y, others for z)
|
||||
* @return the component value corresponding to the specified dimension
|
||||
*/
|
||||
fun vector3Mapper(v: Vector3, dimension: Int): Double {
|
||||
return when (dimension) {
|
||||
0 -> v.x
|
||||
@@ -30,7 +50,13 @@ fun vector3Mapper(v: Vector3, dimension: Int): Double {
|
||||
}
|
||||
}
|
||||
|
||||
/** built-in mapper for [Vector4] */
|
||||
/**
|
||||
* Maps the components of a 4-dimensional vector based on the specified dimension index.
|
||||
*
|
||||
* @param v the 4-dimensional vector containing the components x, y, z, and w
|
||||
* @param dimension the index of the dimension to retrieve; 0 for x, 1 for y, 2 for z, and any other value for w
|
||||
* @return the value of the vector component corresponding to the specified dimension index
|
||||
*/
|
||||
fun vector4Mapper(v: Vector4, dimension: Int): Double {
|
||||
return when (dimension) {
|
||||
0 -> v.x
|
||||
@@ -40,22 +66,3 @@ fun vector4Mapper(v: Vector4, dimension: Int): Double {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JvmName("kdTreeVector2")
|
||||
fun Iterable<Vector2>.kdTree(): KDTreeNode<Vector2> {
|
||||
val items = this.toMutableList()
|
||||
return buildKDTree(items, 2, ::vector2Mapper)
|
||||
}
|
||||
|
||||
@JvmName("kdTreeVector3")
|
||||
fun Iterable<Vector3>.kdTree(): KDTreeNode<Vector3> {
|
||||
val items = this.toMutableList()
|
||||
return buildKDTree(items, 3, ::vector3Mapper)
|
||||
}
|
||||
|
||||
@JvmName("kdTreeVector4")
|
||||
fun Iterable<Vector4>.kdTree(): KDTreeNode<Vector4> {
|
||||
val items = this.toMutableList()
|
||||
return buildKDTree(items, 4, ::vector4Mapper)
|
||||
}
|
||||
Reference in New Issue
Block a user