discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Determining X and Y for the intersection of a conic section and rotated plane given Y

JB
Jordan Brown
Thu, Jun 17, 2021 4:10 PM

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);

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);
FH
Father Horton
Thu, Jun 17, 2021 4:29 PM

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 openscad@jordan.maileater.net
wrote:

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 discuss-leave@lists.openscad.org

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 <openscad@jordan.maileater.net> wrote: > 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 discuss-leave@lists.openscad.org >
WF
William F. Adams
Thu, Jun 17, 2021 4:38 PM

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 fatherhorton@gmail.com
To: OpenSCAD general discussion discuss@lists.openscad.org
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 openscad@jordan.maileater.net wrote:

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 discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

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 <fatherhorton@gmail.com> To: OpenSCAD general discussion <discuss@lists.openscad.org> 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 <openscad@jordan.maileater.net> wrote: 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 discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org