Giter VIP home page Giter VIP logo

Comments (13)

Pomax avatar Pomax commented on September 13, 2024

It probably also depends on what you intend to do: are you trying to find individual points on the surface, are you trying to approximate the surface as a mesh for rendering purposes, etc.

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

In fact I need to calculate the value itself for printing purposes, then I can infer material usage, costs etc.

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

But what is "the value"? A surface has infinitely many values, so what are you actually trying to find?

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

It is the fill of the PolyBezier.

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

Currently I am using pixel counting

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

Are you implementing your own graphics (sub)system? Because most programming languages already come with shape fill solutions =)

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

no, I am not.

Because most programming languages already come with shape fill solutions =)

Please elaborate. I am using plain web vanilla js.

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

The web stack has SVG: creating a <path d="...." stroke="none" fill="red"/> generally does the job for you. And Canvas2D will happily draw an SVG image wherever you need it using the .image function, too, if you're working in bitmap context rather than DOM context.

But of course the best solution will require knowing more about what you're actually working on and how you're implementing that atm.

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

I am building an app that prints letters using CNC
The requirements are to know the surface of each letter (=fill of letter) and the outline. The machine will cut according to the outline and the cost is derived by the surface, the amount of material used.
PolyBezier has made it easy to figure out the outline. Pixel counting is an easy workaround to obtain the fill value. I thought it might need a pure math solution... so I posted this issue.
Regardless I think it is useful to be able to calculate the value using pure math if it isn't too complicated.

Thanks for the help so far!

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

I think we're running into term confusion here: you're not talking about surfaces in relation to Bezier curves, which are a property of 3D curve sets. You're talking about actual physical material surfaces, so: be aware of the fact that the same term in different context can mean a wildly different thing. Don't talk about "bezier surfaces" when you're not talking about 3D surface math, you're just going to confuse math folks =)

So: you looking for a way to efficiently run a CnC bit along a path that will clear the interior of a closed shape. You absolutely don't want to use pixel counting for that, you want to know the dimensions of the CnC bit so that you can trace a path for that bit with minimal overlap. For that, you can just inset the polybezier: if your bit is Xmm, and you want a 10% cut overlap, and you have an initial outline, your first pass will be "that outline, offset by Xmm on the inside", and that's the first cutting pass. Then every subsequent pass is another (X*0.9mm) internal offset.

(i.e. take advantage of the fact that you have parallel contours)

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

take advantage of the fact that you have parallel contours

This is correct most of the time and means that to calculate the fill amount w/o pixel counting I need to split all the contours into segments by the x axis for integral calculation. Can be done but I hoped to avoid it with some clever math.

Thanks for your response and great work

from bezierjs.

ShaMan123 avatar ShaMan123 commented on September 13, 2024

If I do that would you be interested in a contribution exposing a method on PolyBezier? If so please provide a name for it ;)

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

it depends a little on what it does, specifically, but something like sweep might make sense.

from bezierjs.

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.