Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[orx-shapes] rectified t values produce normals and positions with unexpected gap near t=1.0 value #334

Closed
hamoid opened this issue May 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@hamoid
Copy link
Member

hamoid commented May 10, 2024

Operating System

Linux

OPENRNDR version

0.4.5-SNAPSHOT

ORX version

0.4.5-SNAPSHOT

Java version (if applicable)

No response

Describe the bug

Discussed in https://openrndr.slack.com/archives/CARDHCRLG/p1715349495895799

Passing a t value with regular increments produces results which are not regular around 1.0 boundary both for .normal() and .position().

Steps to reproduce the bug

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.shapes.rectify.rectified
import org.openrndr.shape.Circle
import org.openrndr.shape.Segment2D

fun main() = application {
    program {
        val c = Circle(drawer.bounds.center, 50.0).contour
        val rc = c.rectified()
        val normals = List(100) {
            val t = it / 100.0
            val p = rc.position(t)
            val n = rc.normal(t)
            Segment2D(p, p + n * 500.0)
        }
        (normals + normals.first()).zipWithNext { a, b ->
            println(a.end.distanceTo(b.end).toInt())
        }
        extend {
            drawer.clear(ColorRGBa.WHITE)
            drawer.stroke = ColorRGBa.WHITE.shade(0.8)
            drawer.segments(normals)
            drawer.stroke = ColorRGBa.GREEN
            drawer.segment(normals[normals.size - 2])
            drawer.stroke = ColorRGBa.RED
            drawer.segment(normals[normals.size - 1])
            drawer.stroke = ColorRGBa.BLUE
            drawer.segment(normals.first())
        }
    }
}

image

@hamoid hamoid added the bug Something isn't working label May 10, 2024
@hamoid
Copy link
Member Author

hamoid commented May 10, 2024

A workaround is to use .contour.open instead of .contour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant