Making a support structure "manifold" in openscad - openscad

I am trying to build a support structure around a cylinder in openscad, but I cannot seem to make the angled part of the structure "manifold"
inner_slide_tube_inner_radius=14.9/2;
leadpipe_wall_thickness=14.9/2;
leadpipe_length=200;
mouthpiece_receiver_large_radius=0.546*25.4/2;
NoSpokes = 4;
SpokesWide = 3;
SpokesHigh = 3;
SpokesLong = leadpipe_length/2*0.75;
SpokesLong2 = leadpipe_length/2;
//if I comment out this section, then I can render a single support angle part when NoSpokes=1
for (i=[1:NoSpokes])
rotate([0,0,360/NoSpokes*i])
translate([mouthpiece_receiver_large_radius+leadpipe_wall_thickness,-SpokesWide/2,0])
cube([SpokesLong, SpokesWide, SpokesHigh]);
//
for (i=[1:NoSpokes])
rotate([0,0,360/NoSpokes*i])polyhedron(
points=[
[mouthpiece_receiver_large_radius+SpokesLong+leadpipe_wall_thickness-SpokesHigh, -SpokesWide/2, SpokesHigh],
[mouthpiece_receiver_large_radius+SpokesLong+leadpipe_wall_thickness-SpokesHigh, SpokesWide/2, SpokesHigh],
[inner_slide_tube_inner_radius, SpokesWide/2, SpokesLong2],
[inner_slide_tube_inner_radius, -SpokesWide/2, SpokesLong2],
[mouthpiece_receiver_large_radius+SpokesLong+leadpipe_wall_thickness, -SpokesWide/2, SpokesHigh],
[mouthpiece_receiver_large_radius+SpokesLong+leadpipe_wall_thickness, SpokesWide/2, SpokesHigh],
[inner_slide_tube_inner_radius, SpokesWide/2, SpokesLong2+SpokesHigh],
[inner_slide_tube_inner_radius, -SpokesWide/2, SpokesLong2+SpokesHigh]],
faces=[[1,0,3,2],
[1,5,4,0],
[2,3,7,6],
[1,5,6,2],
[0,4,7,3],
[4,5,6,7]
]);
I know that this is really naive question, but I am rather stuck as I keep getting the warning WARNING: Object may not be a valid 2-manifold and may need repair!
Any help would be greatly appreciated to get rid of the warning.

The reason your design is not manifold is that some of your polygon don't have the correct winding order. In OpenSCAD, if you preview your design using F2 (Thrown Together), such wrongly winded polygons will be highlighted in pink.

Related

Document generator, different margins for certain pages

I am creating a document using MATLAB's mlreportgen.dom.*;
I would like to be able to set the first and last page of a document to have no margins. This way I can get images to fit right across the page.
I am having difficulties with this, see example code
import mlreportgen.dom.*;
d = Document('myreport', 'pdf');
open(d);
currentLayout = d.CurrentPageLayout;
pdfheader = PDFPageHeader();
p = Paragraph('Sample Traffic Data in Austin');
p.Style = [p.Style, {HAlign('left'), Bold(true), FontSize('12pt')}];
append(pdfheader, p);
currentLayout.PageHeaders = pdfheader;
currentLayout.PageMargins.Gutter = '0.0in';
currentLayout.PageMargins.Left = '0.0in';
currentLayout.PageMargins.Right = '0.0in';
close(d);
rptview(d.OutputPath);
So far, I have naively tried to add a page break and redefine margins with no success. It appears to use the margins that come last in the document.

Confused about get_rays function in NeRF

I've been trying to understand NeRF. I finished reading the paper(Tancik) and watched some of the videos. I have been looking at some parts of the code. However, I can't quite wrap my head around what the get_rays function does in terms of the code. Could anybody just run through line-by-line about what each line in the the get_rays function is supposed to do?
def get_rays(H,W , focal, c2w): #c2w is pose
i, j = tf.meshgrid(tf.range(W, dtype=tf.float32), tf.range(H, dtype=tf.float32), indexing='xy')
dirs = tf.stack([(i-W*.5)/focal, -(j-H*.5)/focal, -tf.ones_like(i)], -1)
rays_d = tf.reduce_sum(dirs[..., np.newaxis, :] * c2w[:3,:3], -1)
rays_o = tf.broadcast_to(c2w[:3,-1], tf.shape(rays_d))
return rays_o, rays_d
It creates two lists, rays_o represents points where rays originate (camera centre) and rays_d represents direction vectors of each ray casting through the centre of every pixel of the camera. In this case, all values in the rays_o are the same because the function gets rays from a single camera.

Is there a limit to the amount of data you can put in a MATLAB pie/pie3 chart?

I have everything going swimmingly on my pie chart and 3D pie charts within MATLAB for a dataset, however, I noticed that even though I have 21 pieces of data for this pie-chart being fed into the pie-chart call, only 17 appear.
PieChartNums = [ Facebook_count, Google_count, YouTube_count, ThePirateBay_count, StackOverflow_count, SourceForge_count, PythonOrg_count, Reddit_count, KUmail_count, Imgur_count, WOWhead_count, BattleNet_count, Gmail_count, Wired_count, Amazon_count, Twitter_count, IMDB_count, SoundCloud_count, LinkedIn_count, APOD_count, PhysOrg_count];
labels = {'Facebook','Google','YouTube','ThePirateBay','StackOverflow', 'SourceForge', 'Python.org', 'Reddit', 'KU-Email', 'Imgur', 'WOWhead', 'BattleNet', 'Gmail', 'Wired', 'Amazon', 'Twitter', 'IMDB', 'SoundCloud', 'LinkedIn', 'APOD', 'PhysOrg'};
pie3(PieChartNums)
legend(labels,'Location','eastoutside','Orientation','vertical')
This goes for the labels and the physical graph itself.
Excuse the poor formatting in terms of the percentage cluster, this is just a rough version. I tried every orientation and even splitting labels between the orientations without any luck.
Quasi-better resolution for Pie Chart -- Imgur Link
Like Daniel said - it appears that there simply isn't any non-negative data for the missing slices. I tried reproducing your problem with the following initialization, yet it resulted in normal-looking chart:
[ Facebook_count, Google_count, YouTube_count, ThePirateBay_count, ...
StackOverflow_count, SourceForge_count, PythonOrg_count, Reddit_count, ...
KUmail_count, Imgur_count, WOWhead_count, BattleNet_count, Gmail_count, ...
Wired_count, Amazon_count, Twitter_count, IMDB_count, SoundCloud_count, ...
LinkedIn_count, APOD_count, PhysOrg_count] = deal(0.04);
In order to verify this hypothesis - could you provide the data you're using for the chart? Do you get any warnings when plotting the chart?
From inside the code of pie.m:
if any(nonpositive)
warning(message('MATLAB:pie:NonPositiveData'));
x(nonpositive) = [];
end
and:
for i=1:length(x)
if x(i)<.01,
txtlabels{i} = '< 1%';
else
txtlabels{i} = sprintf('%d%%',round(x(i)*100));
end
end
You can see that MATLAB doesn't delete valid slices, but only renames them if the data values are small.

Physicsjs Screen wrap

I am currently having a bit of trouble making objects in my world wrap. It sort of works, but very often objets appear to get stuck on the boundaries. My wrap code is as follows:
// Wrap our position if we are outside of the world bounds
if (this.state.pos.get(0) > 860) {
this.state.pos.set(0, this.state.pos.get(1));
}
else if (this.state.pos.get(0) < 0) {
this.state.pos.set(860, this.state.pos.get(1));
}
if (this.state.pos.get(1) > 640) {
this.state.pos.set(this.state.pos.get(0), 0);
}
else if (this.state.pos.get(1) < 0) {
this.state.pos.set(this.state.pos.get(0), 640);
}
Is there a better way of doing this? Should I use a translation on the object's position vector rather than simply setting it?
Without a jsfiddle it's a bit hard to diagnose, however this might be due to the this.state.old.pos not being set too. If the position (only) is set, then the velocity will be calculated as the difference between the current and the previous positions (in accordance with verlet integration). In that case, you're implicitly giving the body a huge velocity.
I'd recommend adding/subtracting an amount rather than setting, then you can do the same with the old position.
Here's a working example: http://labs.minutelabs.io/Relativistic-Space-Sheep/
With the relevant line of code: https://github.com/minutelabsio/Relativistic-Space-Sheep/blob/master/library/js/mediators/boilerplate.js#L743

different RA/Decs returned by pyEphem

I using pyEphem to calculate RA/Decs of satellites and I'm confused by the different
values computed and described on
http://rhodesmill.org/pyephem/radec.html
this bit of code
sat=ephem.readtle("SATNAME ", \
"1 38356U 12030A 14148.90924578 .00000000 00000-0 10000-3 0 5678",\
"2 38356 0.0481 47.9760 0002933 358.9451 332.7970 1.00270012 3866")
gatech = ephem.Observer()
gatech.lon, gatech.lat = '-155.47322222', '19.82561111'
gatech.elevation = 4194
gatech.date = '2014/01/02 07:05:52'
sat.compute(gatech)
print 'a_ra=',sat.a_ra,'a_dec=',sat.a_dec,'g_ra=',sat.g_ra,'g_dec=',sat.g_dec,'ra=',sat.ra,'dec=',sat.dec
gives
a_ra= 0:52:40.75 a_dec= -3:15:23.7 g_ra= 1:14:10.55 g_dec= 0:06:09.8 ra= 0:53:23.57 dec= -3:10:50.5
if I change JUST the observers location to say
gatech.lon, gatech.lat = '-5.47322222', '19.82561111'
I get
a_ra= 1:15:36.95 a_dec= -2:32:29.9 g_ra= 1:14:10.55 g_dec= 0:06:09.8 ra= 1:16:19.75 dec= -2:28:04.6
I thought the observers position only came into the calculation of sat.ra and sat.dec
so was suprised to see a_ra and a_dec had changed.
What am I missing?
Thanks
Ad
Per the last paragraph of the “body.compute(observer)” section of the Quick Reference:
http://rhodesmill.org/pyephem/quick.html#body-compute-observer
For earth satellite objects, the astrometric coordinates [meaning a_ra and a_dec] are topocentric instead of geocentric, since there is little point in figuring out where the satellite would appear on a J2000 (or whatever epoch you are using) star chart for an observer sitting at the center of the earth.
And in the issue that has been opened about this behavior, the project is open to suggestions about where this text can appear more prominently to prevent future confusion for users:
https://github.com/brandon-rhodes/pyephem/issues/55