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

add arc/pie drawing #68

Open
gokboeruealp opened this issue Jun 4, 2024 · 1 comment
Open

add arc/pie drawing #68

gokboeruealp opened this issue Jun 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gokboeruealp
Copy link

Is there any way to convert ellipse class to arc/pie class.

override fun assembleGeometry(rc: RenderContext) {
    super.assembleGeometry(rc)
    val startRadians = Math.toRadians(startAngle)
    val endRadians = Math.toRadians(endAngle)

    val totalAngle = if (endAngle >= startAngle) {
        endRadians - startRadians
    } else {
        (endRadians + 2 * Math.PI) - startRadians
    }

    val stepCount = (totalAngle / Math.toRadians(1.0)).toInt()
    val angleStep = totalAngle / stepCount

    val vertexList = mutableListOf<Float>()
    vertexList.add(0f)  
    vertexList.add(0f)

    for (i in 0..stepCount) {
        val currentAngle = startRadians + i * angleStep
        val x = ((distanceInMeters / GlobeObject.getWorldWindow().engine.globe.equatorialRadius*70) * Math.cos(currentAngle)).toFloat()
        val y = ((distanceInMeters / GlobeObject.getWorldWindow().engine.globe.equatorialRadius*70) * Math.sin(currentAngle)).toFloat()
        vertexList.add(x)
        vertexList.add(y)
    }

    if (vertexArray.size != vertexList.size) {
        vertexArray = FloatArray(vertexList.size)
    }
    for (i in vertexList.indices) {
        vertexArray[i] = vertexList[i]
    }
}

image

@ComBatVision
Copy link
Member

You may try to implement it and propose a pull request. This is a good idea and should not be very complex.

@gokboeruealp gokboeruealp changed the title How to draw arc/pie? add arc/pie drawing Jun 7, 2024
@ComBatVision ComBatVision added the enhancement New feature or request label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants