Nabble removed Mailing-list integration from the Forum.
This killed the Forum. This is now an ARCHIVE.
It is likely Nabble will shutdown in the future.
I have this shape:
//!OpenSCAD
$fn=80;
difference(){
translate([0, 0.125, 0.25]){ rotate([0, 90, 0]){ cylinder(r1=0, r2=0.125, h=(0.125 / tan(15)), center=false); } } union(){ cube([1, 1, 0.25], center=false); rotate([0, 45, 0]){ cube([1, 1, 1], center=false); } } } (a cone rotated so that the tip points to the left and cut off at 45 degrees by a plane running from 0,0,0 up to the right)
For a given Y, how do I calculate the X and Y of the intersection of the cone and the plane? I want to step through it and essentially draw a series of lines along the top of the shape.
All the math I've found for this is in terms of polar coordinates which I can't puzzle out how to make work in OpenSCAD, or I'm just not understanding something --- references to a good textbook on this would be welcome as well.
William
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
This may be useful, although I fear a substantial amount of maths lies ahead!
https://www.quora.com/What-is-intersection-of-a-true-cone-and-a-plane Terry Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Thanks!
I'll look at it ---and of course, there was a typo in my post: "For a given Y, how do I calculate the X and Y of the intersection of the cone and the plane? I want to step through it and essentially draw a series of lines along the top of the shape." should instead be:
For a given Y, how do I calculate the X and _Z_ of the intersection of the cone and the plane? I want to step through it and essentially draw a series of lines along the top of the shape.
William
-----Original Message-----
From: Terrypin <[hidden email]> To: [hidden email] Sent: Thu, Jun 17, 2021 10:46 am Subject: [OpenSCAD] Re: Determining X and Y for the intersection of a conic section and rotated plane given Y This may be useful, although I fear a substantial amount of maths lies ahead!
https://www.quora.com/What-is-intersection-of-a-true-cone-and-a-plane Terry Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________
OpenSCAD mailing list To unsubscribe send an email to [hidden email] _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
It should also be somewhat simplified (!) because that intersection angle of 45 degs makes the intersection curve an ellipse. That has a relatively accessible equation (compared to the hyperbola) which might help you avoid polar co-ordinates.
My trig studies were decades ago, so hopefully someone with genuine expertise will come to your aid shortly ;-) Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by OpenSCAD mailing list-2
I'm not really following what you're trying to do, but I can provide
a couple of tidbits.
First, what's your real use case? If you just want to chop the cone off, you could have OpenSCAD do that without you needing to know the coordinates. Second, polar coordinates... Wikipedia is always a good place to start: https://en.wikipedia.org/wiki/Polar_coordinate_system https://en.wikipedia.org/wiki/Spherical_coordinate_system Here's some functions: // Given an [x,y] or [x,y,z], transform to a // [rho, theta] or [rho, theta, phi]. // Note that in mathematical spherical coordinates, // phi is measured down from vertical. This is as // opposed to geographic coordinates, where latitude // is measured up from the equator. function topolar(p) = len(p) == 3 ? topolar3(p) : topolar2(p); function topolar2(p) = [ norm(p), atan2(p.y, p.x) ]; function topolar3(p) = [ norm(p), atan2(p.y, p.x), atan2(norm([p.x,p.y]), p.z) ]; // Given a [rho, theta] or [rho, theta, phi], transform to // an [x,y] or [x,y,z]. function torect(p) = len(p) == 3 ? torect3(p) : torect2(p); function torect2(p) = [ p[0] * cos(p[1]), p[0] * sin(p[1]) ]; function torect3(p) = [ p[0] * cos(p[1]) * sin(p[2]), p[0] * sin(p[1]) * sin(p[2]), p[0] * cos(p[2]) ]; echo(topolar([10,0])); echo(topolar([10,1])); echo(topolar([10,10])); echo(topolar([-10,10])); echo(topolar([-10,-10])); echo(topolar([10,-10])); echo(); echo(topolar([10,0,0])); echo(topolar([10,1,0])); echo(topolar([10,10,10])); echo(topolar([-10,10,10])); echo(topolar([-10,-10,10])); echo(topolar([10,-10,10])); echo(); rho = 100; for (theta = [0:10:70]) for (phi=[0:10:70]) translate(torect([rho, theta, phi])) cube(1); _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
A conic section is always a circle (OpenSCAD primitive), an ellipse (easily achievable in OpenSCAD via scaling a circle), or an unbounded curve (parabola, hyperbola) which I'd probably approximate unless I needed a really precise version. So I too wonder what the use case is, and whether there's an easier way. On Thu, Jun 17, 2021 at 11:11 AM Jordan Brown <[hidden email]> wrote:
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
What I need to do is to draw lines, which terminate at the intersection of the plane and the cone, either:
(but I don't think that will work 'cause the needed shape would be a curve, not a straight line)
So more probably:
So for a given Y, (sectioning along the length of the cone), I need to calculate X and Z, so I can feed it into a loop which has a module iterate on moving a V endmill across that.
William
-----Original Message-----
From: Father Horton <[hidden email]> To: OpenSCAD general discussion <[hidden email]> Sent: Thu, Jun 17, 2021 12:29 pm Subject: [OpenSCAD] Re: Determining X and Y for the intersection of a conic section and rotated plane given Y A conic section is always a circle (OpenSCAD primitive), an ellipse (easily achievable in OpenSCAD via scaling a circle), or an unbounded curve (parabola, hyperbola) which I'd probably approximate unless I needed a really precise version. So I too wonder what the use case is, and whether there's an easier way.
On Thu, Jun 17, 2021 at 11:11 AM Jordan Brown <[hidden email]> wrote:
_______________________________________________
OpenSCAD mailing list To unsubscribe send an email to [hidden email] _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Sorry, I'm still not visualizing what you're looking for.
Perhaps you could supply the OpenSCAD program, so that one could look at the result in 3D? Are you just looking for the line along the intersection of a cone and a plane? (Not that I immediately know how to calculate that, but I might be able to figure it out. Where's one of the serious math people when you need them? :-) _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by OpenSCAD mailing list-2
Or https://www.dropbox.com/s/5w3ybt5gmscpvw8/ConeProject-1.jpg?dl=0httraw=1 Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Drawing the lines first isn't an option --- I need to match a differently cut part and need to get from the left (the tip of the cone) to the right (the ellipse where the cone and plane intersect at X and Z based on knowing Y (I'll be looping through).
I've tried doing it w/ trigonometry, and it's a long series of nested calculations which seem cumbersome and slow to calculate even before I get halfway there.
William
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
I'm not sure if I really understand what you're trying to do, but it seems like a simple approach is to sweep over the lines on the cone and calculate their intersection with the plane. The easiest way to do this I show below, which uses evenly spaced angles around the cone. But you could sample some other way. BOSL2 has code for line-plane intersection...or you can write your own if you prefer to do more work. You could of course also draw the lines at full length (to the base of the cone) and then difference away the excess length, but it seems like there's some reason you don't want to do it that way? As I said...I don't quite understand what you're trying to do. Are you trying to intersect with something more complex than just a plane?
include<BOSL2/std.scad> $fn=80; difference(){ translate([0, 0.125, 0.25]) rotate([0, 90, 0]) cylinder(r1=0, r2=0.125, h=(0.125 / tan(15)), center=false); cube([1, 1, 0.25], center=false); rotate([0, 45, 0]) cube([1, 1, 1], center=false); } plane = plane_from_normal([-1,0,1]); apex = [0, 1/8, 1/4]; rbase = 0.125; h = 0.125/tan(15); N = 16; base = [for(i=[0:1:N/2]) let(theta=360*i/N) apex+[h,rbase*cos(theta), rbase*sin(theta)]]; color("red") for(pt=base){ int = plane_line_intersection(plane, [apex, pt]); stroke([apex,int], width=0.005); }
Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Thank you.
What I'm trying to do is to feed X and Z into a module along w/ Y so that I can write out the coordinates.
Unfortunately, I can't figure out how to unwrap your code to fit the requirements of the module I worked up:
include<BOSL2/std.scad>
$fn=80;
difference(){ translate([0, 0.125, 0.25]) rotate([0, 90, 0]) cylinder(r1=0, r2=0.125, h=(0.125 / tan(15)), center=false); cube([1, 1, 0.25], center=false); rotate([0, 45, 0]) cube([1, 1, 1], center=false); } plane = plane_from_normal([-1,0,1]);
apex = [0, 1/8, 1/4]; rbase = 0.125; h = 0.125/tan(15); N = 16; //base = [for(i=[0:1:N/2]) let(theta=360*i/N) apex+[h,rbase*cos(theta), rbase*sin(theta)]]; color("red")
// for(pt=base) for(i=[0:1:N/2]) { // int = plane_line_intersection(plane, [apex, pt]); stroke([apex,plane_line_intersection(plane, [apex, pt])], width=0.005); } I want to have separate access to the X, Y, and, Z coordinates:
module cutv(bx, by, bz, ex, ey, ez, r, a) {
hull(){ translate([bx, by, bz]){ vendmill(r, a); } translate([ex, ey, ez]){ vendmill(r, a); } } } (see below for the dependencies)
Eventually the module will be extended to write out the coordinates as G-Code using echo.
Another limitation is I do most of my development in BlockSCAD, which I guess makes my code overly simplistic/procedural/stilted.
William
module vendmill(vr, va) {
union(){ removevshape(vr, va); translate([0, 0, (calcVdepth(vr, va))]){ cylinder(r1=vr, r2=vr, h=st, center=false); } } } module removevshape(vr, va) { cylinder(r1=0, r2=vr, h=(calcVdepth(vr, va)), center=false); } function calcVdepth(rad, an) = rad / tan(an);
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Is the following correct?
For a given value y, you want two formulae: x = Fx(y) and z = Fz(y) And it's important that your cone is orientated exactly as you have specified, rather than in some other position that might make the calculations easier? If Yes to both then I expect other functions in BOSL2 could deliver that, in the hands of somone like Adrian. But it should also be possible from first principles and grunt work. Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by OpenSCAD mailing list-2
I still don't really understand what you need. The code I wrote does provide separate access to the x, y and z coordinates. That is, the final loop that draws the lines is producing the line endpoints (in the "int") variable, so int.x, int.y and int.z are the separate coordinates of the end of the line that traces the ellipse.
If you want to be able to specify a y and get the corresponding x and z then the same approach works. You just have to sample the cone at the specified y instead of by angle. I suggested this approach because it appears to be the simplest way to get (what I thought) you wanted. It requires the smallest amount of mathematical knowledge. You can of course just write down the equation of your cone and the equation of your plane and substitute the plane equation into the cone equation to get an equation for the ellipse, and then you can plug in y and get x and z out. I was less enthusiastic about that approach because it means more work for the human instead of leaning on the computer to do the work for you. It's a math solution instead of an OpenSCAD solution. Your cone has an equation like y^2+z^2=(tan(15)*x)^2 and the plane is something like -x+z=0. So subsitute x=z into the first, and solve, You get x=real_roots([ 1-sqr(tan(15)), -2*apex.z, sqr(apex.z)+sqr(y-apex.y)], using BOSL2, but it's just a quadratic so you can use the quadratic formula.
Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Thanks!
As I noted, I wasn't able to get the numbers out of your code, but with the explanation you've provided I think I'll be able to puzzle things out.
William
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Free forum by Nabble | Edit this page |