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=360i/N) apex+[h,rbasecos(theta),
rbase*sin(theta)]];
color("red")
for(pt=base){
int = plane_line_intersection(plane, [apex, pt]);
stroke([apex,int], width=0.005);
}
http://forum.openscad.org/file/t2477/cone.png
OpenSCAD mailing list-2 wrote
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
discuss-leave@.openscad
--
Sent from: http://forum.openscad.org/
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=360i/N) apex+[h,rbasecos(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);