GithubHelp home page GithubHelp logo

coordinates of a Polygon about geometrybasics.jl HOT 4 CLOSED

visr avatar visr commented on September 25, 2024
coordinates of a Polygon

from geometrybasics.jl.

Comments (4)

visr avatar visr commented on September 25, 2024 1

That only gives back the first two points, that make up the first line. I could loop over the lines and pick out the right ends, but there is probably a more direct / faster way.

from geometrybasics.jl.

Sov-trotter avatar Sov-trotter commented on September 25, 2024 1

Yeah I am slowly realizing that the inherent geometrybasics methods like that I have used above don't quite support our use case(Makie).

I could loop over the lines and pick out the right ends, but there is probably a more direct / faster way.

I am trying to do a similar thing in the above referenced PR.
Here's something I tried as per the above PR.

using BenchmarkTools
pts = collect(Point{2, Float64}(x/2, (x+1)/3) for x in 1:10000)

ls = LineString(pts)

@btime ls.points.parent.data
128.521 ns (6 allocations: 192 bytes)
10000-element Array{Point{2,Float64},1}:

from geometrybasics.jl.

knuesel avatar knuesel commented on September 25, 2024 1

This can be closed now that #73 is merged?

from geometrybasics.jl.

Sov-trotter avatar Sov-trotter commented on September 25, 2024

I think this is more like a nested structure. Where we can't get to the point directly, but something like this works :

pts = Point{2, Int}[(3, 1), (4, 4), (2, 4), (1, 2), (3, 1)]
pol = Polygon(pts)
ngon = decompose(GB.Ngon, pol.exterior)
coordinates(ngon[1])

Also some nested decomposition works,

ngon = decompose(GB.Ngon, pol.exterior)
point = decompose(Point, ngon[1])

The stacktrace kinda hinted it,

Stacktrace:
[1] (::GeometryBasics.var"#152#153"{Int64,GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},Int64})(::Int64) at C:\Users\visser_mn.julia\dev\GeometryBasics\src\geometry_primitives.jl:57
Also like you said here,
Because this seems a bit inconsistent at times, as we saw above coordinates(::Polygon) returns lines, but if we put in an Ngon, a fixed size polygon, then we get the points:

from geometrybasics.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.