Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Exponential horn along spline or collection of edges

mathias_nielsenmathias_nielsen Member Posts: 2 ✭✭
Hi.
I am trying to create a model of a back loaded horn speaker.
This basically means calculating a horn shape according to parameters for the speaker and then try to fold this horn in order for it to fit inside a reasonably sized box.

Traditionally this has meant producing cases looking like this:


But since more and more have access to CNC equipment (myself included) a new design have seen wider adoption in the later years:


This last one is what I am trying to do.
I have the calculations for the horn down, but it would be nice if I could make onshape do all the hard work by simply having it follow a single spline or a selection of edges and then drawing a line on each side that follows along, but at a distance that increases according to the formulae that I have.

I have tried looking at creating a new feature for this, but I am a little stuck as to which operation will helt me acheive what I want.

Neither sweep nor loft seems to be able to do what I want, even when used from a custom feature script, but I may be wrong.

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    This looks like an extrusion to me (with a profile bounded by two splines).  So in FS what I would probably do is take a 2D spline as input (it's a bit more work if it's a selection of edges), evaluated the tangent at a number of points, generate points by offsetting according to your formulas in the direction perpendicular to the tangent and then making a sketch with two skFitSpline calls and something to close the boundary so you can extrude the profile.

    Here's the type of thing:
    https://cad.onshape.com/documents/fca50f3961de676b0120b395/w/e48c0296ca8911efccdddbe2/e/429fc52647065a78f3eb308e


    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • mathias_nielsenmathias_nielsen Member Posts: 2 ✭✭
    I just knew there was a way to do it. Thank you, very nice idea.

    I think I can even make it work for a selection of edges provided I remember correctly that there is a way to get the length of an edge even if it's a curve.

    In any case, thank you very much for the input.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    Sure.

    Yes, evLength will get you the edge length.  The challenge with multiple edges is that they may be selected in arbitrary order and some may be flipped.  The curve pattern example has some code for dealing with these issues.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,071 PRO
    edited July 2016
    Was thinking about this last night, can't help but chime in.

    Seems like there's a trivial solution to this problem.

    Here's a curve:


    Counting the inflections, you'll know the order of the curve, or in the cubic spline world the number of curve segments required. I wouldn't use arcs or lines make everything a spline possibly a multi-node spline.

    Consider the entire length of path as 100%:


    Step along your path at some increment and figure out which spline segment you're on top of. Take the 1st derivative of spline segment and compute tangent vector at the path increment (OS should provide this, haven't looked, but if not it's easy to compute if you know spline segment coefficients). Take triple product and get a normal direction from the tangent. Offset along the normal based on percent traveled and create a point in an array to be used later when creating a spline. Highlighted tangent vector on curve at a point:


    Let's pretend your algorithm created all these points:


    Create a spline using points in your array:


    Obviously my exponential horn looks poor because I eyeballed in the node placement for the fit spline. I also only went half way. I guess I'm representing an exponential horn featurescript that needs debugging.

    My original thought was to have the normal offset be linearly proportional to the traveled length, but there's no reason why you couldn't make it exponential x^2. Give you what you asked for.

    Also, after it's up and running. I'd keep the last tangential vector in a variable and dot it with the newly computed one keeping track of the angle between them. As the angle increases (meaning you are changing curvature) decrease your increment value to give you greater resolution as your exponential  curve is being created around curvature and when it straightens out use fewer points.

    This would be a fun featurescript to play around with. Not sure about it's applications other than creating a bass port for your speaker.

    Could featurescript do this? I haven't researched it. Should be able to since this is trivial CAD. I'd look for tangent vector to curve in the library. Should be in there. Use their functions in OS when possible as they'll be faster than any interpolated algorithm you write in featurescript.

    I'd write this in 3D even though my path curve is 2D. 3D is just another term in the equations and would make your script more versatile. Follow an edge? Sure why not. If you've ever done this, you'll know picking the reference for your triple product becomes problematic. These guys do a good job at these strategies but they won't a share. This is where the math turns into art.



    As always, when you finish it please share I'd like to see it.



  • john_self672john_self672 Member Posts: 1
    Hi Mathias, have you made any progress with this great looking speaker? I also want to build it so it would be great if you could post the CAD/CAM files if available. Any news?
Sign In or Register to comment.