openscad - 3d z dvou ploch
Jaroslav Buchta
jaroslav.buchta na hascomp.cz
Neděle Duben 19 18:25:45 CEST 2020
Jj, hned jak jsem no poslal tak jsem to nasel ;-)
Jako reseni to zda se je, renderuje to i prekvapive rychle. Zatim
zkusebni program vypada takhle:
function circlepts(xc, yc, a1, a2, r, segments, z) =
[for (i=[0:segments-1]) [
xc + r*sin(a1 + (a2-a1)/(segments-1)*i),
yc + r*cos(a1 + (a2-a1)/(segments-1)*i),
z]
];
function basepts(z, ext) = concat(
[[-ext,-ext,z]],
circlepts(28-ext, 115+ext, -90, -30, 28, 30,z),
circlepts(28+ext, 115+ext, 30, 60, 28, 30,z),
circlepts(63.5+ext, 133+ext, 240, 180, 12, 20,z),
circlepts(115, 116+ext, 0, 90, 5, 10,z),
circlepts(115, 105, 90, 270, 5, 20,z),
circlepts(102, 106, 90, 0, 8, 20,z),
circlepts(91, 104, 0, -180, 10, 20,z),
circlepts(115, 100, 250, 180, 20, 30,z),
[[132+ext,80,z]],
circlepts(122+ext, 75-ext, 90, 180, 10, 20,z),
circlepts(90+ext, 30-ext, 0, -90, 35, 30,z),
[[55+ext,0-ext,z]]
);
module basepoly()
{
ptsb = basepts(0, 0);
ptst = basepts(20, 6);
faceb = [[for (i=[0:len(ptsb)-1])i]];
facet = [[for (i=[0:len(ptst)-1])2*len(ptsb)-i-1]];
faces = [for (i=[0:len(ptsb)-1])[i + len(ptsb), i != len(ptsb)-1 ?
i + len(ptsb)+1 : len(ptsb), i != len(ptsb)-1 ? i+1 : 0, i]];
echo ( concat(facet, faces, faceb));
polyhedron(concat(ptsb, ptst), concat(facet, faces, faceb), 10);
}
basepoly();
Dne 19.04.2020 v 18:07 Milan B. napsal(a):
> On 19.04.2020 16:52, Jaroslav Buchta wrote:
>> ale marne patram, jak zjistit velikost vektoru (jasne da se iterovat
>> pres vsechny prvky ale potrebuju index - no ono by to nakonec asi
>> takhle taky slo spocitat ale rovnak na ohejbak...)
>
> Toto nevyhovuje?
> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Functions#len
>
> a=[[1,2,4],[3,4,5],[5,6,7]];
>
> n=len(a);
>
> for (i=[0:n-1]) {
> echo(sqrt(a[i].x*a[i].x+a[i].y*a[i].y+a[i].z*a[i].z));
> }
>
>> Dne 19.04.2020 v 14:07 Pavel Hudecek napsal(a):
>>>
>>> Napsal bych si program ve VB, kterej ten polyhedron vygeneruje.
>>>
>>> PH
>>>
>>> *Od: *Jaroslav Buchta <mailto:jaroslav.buchta na hascomp.cz>
>>> *Odesláno:*neděle 19. dubna 2020 14:01
>>> *Komu: *hw-list na list.hw.cz <mailto:hw-list na list.hw.cz>
>>> *Předmět: *Re: openscad - 3d z dvou ploch
>>>
>>> No jedna se o stovky bodu, je to nasledujici tvar - to je obrys
>>> spodni plochy, horni plocha by byla definovana podobne jen obrys
>>> vetsi ruzne na ruznych mistech, ale jak z toho udelat polyhedron mne
>>> nenapada...
>>>
>>>
>>> function circlepts(xc, yc, a1, a2, r, segments) =
>>> [for (i=[0:segments-1]) [
>>> xc + r*sin(a1 + (a2-a1)/(segments-1)*i),
>>> yc + r*cos(a1 + (a2-a1)/(segments-1)*i)]
>>> ];
>>>
>>>
>>>
>>> module basepoly()
>>> {
>>> //translate([-132/2, -133/2])
>>> polygon(points=concat(
>>> [[0,0], [0,115]],
>>> circlepts(28, 115, -90, -30, 28, 30),
>>> circlepts(28, 115, 30, 60, 28, 30),
>>> circlepts(63.5, 133, 240, 180, 12, 30),
>>> [[115,121]],
>>> circlepts(115, 116, 0, 90, 5, 10),
>>> [[120,105]],
>>> circlepts(115, 105, 90, 270, 5, 20),
>>> circlepts(102, 105, 90, 0, 8, 20),
>>> [[81,113]],
>>> circlepts(91, 103, 0, -180, 10, 20),
>>> circlepts(115, 100, 250, 180, 20, 30),
>>> [[132,80], [132, 75]],
>>> circlepts(122, 75, 90, 180, 10, 20),
>>> [[90,65]],
>>> circlepts(90, 30, 0, -90, 35, 30),
>>> [[55,0]],
>>>
>>> [[0,0]]
>>> )
>>> );
>>> }
>>>
>>> linear_extrude(height=20, convexity=10, scale=1.0, center = false)
>>> basepoly();
>>>
>>> Dne 19.04.2020 v 13:52 Pavel Hudecek napsal(a):
>>>
>>> Jestli je to nadefinované jako skupiny bodů, šlo by z toho udělat
>>> polyhedron.
>>>
>>> PH
>>>
>>> *Od: *Jaroslav Buchta <mailto:jaroslav.buchta na hascomp.cz>
>>>
>>> Dejme tomu, ze mam 2 skicy plochy slozitejsiho tvaru, jde provest
>>> nejaka
>>>
>>> transformace, ktera z toho udela 3D objekt ktery bude mit zakladnu
>>>
>>> odpovidajici jedne a horni stranu druhe plose? Aby proste vznikly
>>> sikme
>>>
>>> steny (scale u linear_extrude nedava dobry vysledek, tvar neni
>>> rozumne
>>>
>>> centrovatelny)
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>> HW-list mailing list - sponsored bywww.HW.cz <http://www.HW.cz>
>>>
>>> Hw-list na list.hw.cz <mailto:Hw-list na list.hw.cz>
>>>
>>> http://list.hw.cz/mailman/listinfo/hw-list
>>>
>>>
>>> _______________________________________________
>>> HW-list mailing list - sponsored bywww.HW.cz
>>> Hw-list na list.hw.cz
>>> http://list.hw.cz/mailman/listinfo/hw-list
>>
>>
>>
>> _______________________________________________
>> HW-list mailing list - sponsored by www.HW.cz
>> Hw-list na list.hw.cz
>> http://list.hw.cz/mailman/listinfo/hw-list
>
>
> _______________________________________________
> HW-list mailing list - sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list
Další informace o konferenci Hw-list