All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.rectify.RectifiedPath3D.kt Maven / Gradle / Ivy

There is a newer version: 0.4.5-alpha6
Show newest version
package org.openrndr.extra.shapes.rectify

import org.openrndr.math.Vector3
import org.openrndr.shape.Path3D
import kotlin.math.floor

class RectifiedPath3D(contour: Path3D, distanceTolerance: Double = 0.5, lengthScale: Double = 1.0) :
    RectifiedPath(contour, distanceTolerance, lengthScale) {

    val path: Path3D get() = originalPath as Path3D

    override fun sub(t0: Double, t1: Double): Path3D {
        if (path.empty) {
            return Path3D(emptyList(), false)
        }

        return if (path.closed) {
            path.sub(rectify(t0.mod(1.0)) + floor(t0), rectify(t1.mod(1.0)) + floor(t1))
        } else {
            path.sub(rectify(t0), rectify(t1))
        }
    }

    override fun splitAt(ascendingTs: List, weldEpsilon: Double): List {
        @Suppress("UNCHECKED_CAST")
        return super.splitAt(ascendingTs, weldEpsilon) as List
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy