Wikipedia:Reference desk/Archives/Computing/2009 March 9

From Wikipedia, the free encyclopedia
Computing desk
< March 8 << Feb | March | Apr >> March 10 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


March 9[edit]

Pointers/References C++[edit]

Alright, I have been trying to figure out in what circumstances each of the following would be useful and how efficient each is, but in the process, have only confused myself further. One particularly confusing thing is that I know that * represents th dynamic allocation of memory, such as in the case of a dynamic integer array, but what does it mean when used with a class?

int get(MyClass* x)
{
return(x->get());
//Will this cause a memory leak?
}
int get(MyClass &x)
{
return(x.get());
}
int get(MyClass x)
{
return(x.get());
//I know this one is not very efficient, but why would you use it?
}

Any help would be greatly appreciated.

Also, what does this do?

int get(MyClass* &x)
{
return(x->get());
}

Nkot (talk) 01:55, 9 March 2009 (UTC)[reply]

I don't want to answer your homework questions, but I just want to say a few things. First, * in the type indicates a pointer type. Pointers can point to anything. Sure, this could include dynamically-allocated objects; but it could be anything else. You can take the address of any variable and you would have a pointer. You should really read up on pointers; the topic is very large and one cannot go into all the details here. Second, no code you've posted has any memory leaks. No dynamic memory allocation is done anywhere in that code. You should get rid of this * = dynamically memory allocation notion because those things are completely unrelated. --76.167.241.45 (talk) 07:31, 9 March 2009 (UTC)[reply]
As .45 says, you need to do more reading, but I do want to say the fundamental de-mystery-ificating thing about pointers: it's just a number. If you think about all the memory in your computer being a big array, a pointer is nothing more than the index of the pointed-to thing in that array. Obviously just mentioning that index does not create anything new, so there can be no memory leak by just using a pointer. --Sean 13:57, 9 March 2009 (UTC)[reply]

How would you recommend organizing digital media (photos, videos, maybe audio in future)[edit]

I'm building up a collection of mainly photos and some videos too, and I'm not sure how best to organize them. My home PC is a windows one, and the folder system there is useless because you can only place an image in one folder (or redundantly copy it into many folders). How else can I organize them? I don't think they're all worth uploading online, and it would probably be more work anyway. I quite like the organization of a wiki (to the point that many non-wiki sites annoy me); perhaps having my own offline wiki would be a good solution? It could also be used for other purposes too, like keeping a record of the species I've seen, to-do lists etc. Has anyone had any experience with this sort of thing? Do you have other ways of organizing your files? If I do use a wiki, where should I get one from? Does GNU/Linux or similar systems have better file organization? Richard001 (talk) 07:00, 9 March 2009 (UTC)[reply]

Am I completely off-base or are you not simply looking for photo album software? Every one since the dawn of time supports tagging photos (allowing multiple categories per photo). I think Google Picassa should do nicely. As to storing the photos on your HD, I always name my folders as YYYY-MM-DD Event. Doesn't help me to group together photos of e.g. flowers, but then again I'm more interested in keeping photos of events together. Zunaid 10:07, 9 March 2009 (UTC)[reply]

Folder-setup is largely irrelevant if you have a good application/operating system. Picasa is highly recommended for photos, not sure if it takes video as not used it for a few years. It also includes decent editing stuff and it's free. Not free, but a professional product and truly wonderful, is Adobe Lightroom but that is not really a 'storage' unit (though it performs the job) it is more a photo-management suite. 194.221.133.226 (talk) 14:26, 9 March 2009 (UTC)[reply]

I'm not sure I understand what you mean when you say "...the folder system is useless because you can only place an image in one folder..." You are free to create, move, copy, and delete folders in Windows. You are also free to copy, move, ... etc. individual files to whichever folder you prefer. If you are referring to the hierarchical structure in the MS file system vs. the trend to 'tag' files with 'keywords' - then yes, various software programs can help with that type of organization. Programs like Thumbs Plus, Windows Live Photogallery, (download.live.com) and the programs mentioned above could fill your needs. I got away from Picasa (other than an occasional lighting tweak) because of it's nature to duplicate the actual files within it's own program's file system - but like User:194..., I haven't tried any new versions in a while. As Zunaid mentions, you're free to name your folders in the manner that best suits your particular needs. If you want to clarify a particular need or question, I'm sure someone can help point you in the right direction. ;) — Ched ~ (yes?) 17:57, 9 March 2009 (UTC)[reply]
If you are still interested in the wiki option, try MoWeS. Instructions are here. I have it et up, and I love it! Thanks, Genius101Guestbook 19:33, 9 March 2009 (UTC)[reply]

Thanks for your responses, I'll look into these options. Richard001 (talk) 06:41, 11 March 2009 (UTC)[reply]

programming a physics engine?[edit]

Can someone suggest how one would go about programming a physics engine like those used in computer games? I don't want too much detail, just point me in the right direction. And what program might you suggest is a good place to start learning this subject area. —Preceding unsigned comment added by Dbjohn (talkcontribs) 13:33, 9 March 2009 (UTC)[reply]

You could do worse than reading the source code of one of the several open source packages listed here. Also, here's a book called "Game Physics Engine Development", which seems relevant. --Sean 14:03, 9 March 2009 (UTC)[reply]
The type of physics needed would vary dramatically with the game. Obviously there are some games where no physics is required at all. Then there are others, like those with space ships firing at each other in space, which require nothing more than constant acceleration and maybe collisions. A game set on Earth (or some other planet) would need to account for gravity and air resistance, too. Then we get into really complex physics like fluid dynamics and finite element modeling for explosions. At this point it's likely the game designers would just "fake it" with a small number of fixed explosion clips, rather than actually model them mathematically within the game. StuRat (talk) 23:22, 9 March 2009 (UTC)[reply]
And StuRat hasn't even got into model physics. Most games have model animations. The model is a single entity that reacts to the world with preset animations. Ever notice that when you kill the monsters in most games they always die the same way? Other games, like Little Big World for a current example), use sackboy or beanbag models. The components of the model interact with the physics of the world independently, allowing a unique animation for each event. -- kainaw 23:25, 9 March 2009 (UTC)[reply]
I'll tell you - it's a major undertaking and most definitely not something you should attempt unless you have a ton of experience playing with existing physics engines. The problems are all in the horrible details. Suppose we have a world where the only objects are simple cubes - the ground is dead flat - there is no air resistance, a simple 'school-boy' model of friction - and there is gravity. That's about as simple as it could ever be (usefully anyway). We have very simple and well known classical mechanics equations for all kinds of rigid-body interactions. There is no unknown physics here...it's been well known for maybe 200 years. How hard could it possibly be?
Well, what's difficult is that computer software has to quantize time into whatever intervals the game is iterating at (say 30 times per second - ~33 milliseconds per time 'step'). What you find is that you're going through all of your objects saying "Accelleration = sum-of-forces / mass", "Velocity = old Velocity + Acceleration / 33msec", "Position = old Position + Velocity / 33msec" - this is a bit of a work-out for your knowledge of high-school mechanics - especially if you blanked a bit on coefficients of rotational inertia, tensors, torque and such. Doing arbitary cube-on-cube collision testing is a pain because of all manner of special cases...But you CAN do it without any serious college-level math - it's not that hard. This is definitely not the problem.
But then (because time is 'quantized') you notice that two objects that weren't touching on your last cycle have moved a bit over the past 33msec - and are now beyond 'touching' - they are partially embedded inside each other. In the real world, they wouldn't do that - they should stop when they collide and possibly bounce off a bit with some kind of elastic collision (which we understand how to do). But the laws of physics fail us here - real world solid objects simply don't "overlap" on a day to day basis! So now you've somehow got to work backwards in time to partway through the 33msec time step to the precise instant when the collision happened (not a trivial matter for objects with complex shapes that are tumbling!)...then you 'reverse time' - back everything up to the point of the collision - compute the consequences of the collision and then figure out what happens as a result of that change. But that backing-up of time causes calculations you already did to be incorrect - and you can go round and round fixing things up - and NEVER get to the end of the process! Just imagine something as seemingly simple as a pile of stationary cubes sitting on top of each other. Each one tries to fall under gravity - so it interpenetrates the one beneath with one of it's four vertices on the bottom sticking into the topmost face of the cube below. But all of the cubes are interpenetrated a bit - backing whichever one you first test back to where it's just touching the one beneath it isn't too terrible - but after you fix that up, the one beneath it hits the one beneath THAT....this in turn messes up other things you've already done...it gets ugly fast.
Ideally, you'd want to solve the equations for all motion of all objects to find when the next intersection is - but that's a HORRIFIC amount of arithmetic - for even a fairly simple scene, you could easily be solving 100,000 equations with 100,000 unknowns - and you've only got a few milliseconds to do the math because in that 1/30th second you've also got to draw the graphics, figure out the AI, read the joystick...you name it!! You really can't do it...and as fast as computers increase in performance, game players expectations rise - so when you get twice the compute power, you'll be expected to do physics on twice the number of objects (which is generally four times the number of collisions!)
What most software does is to cheat - abandoning "real" physics and saying that when one object interpenetrates another - we'll simply create a fake force that pushes the buried objects apart as if they were made of jello. A "restoring force" if you like. But if the force is too small, our pile of cubes wobbles and shakes just like jello (well, duh!). To make objects that behave 'stiffly' like blocks made of steel or something - then under these kinds of collisions you need HUGE restoring forces - and the problem with that is that these forces don't obey the laws of thermodynamics! You're injecting 'free' energy into the system. Now if you take your pile of cubes is that they 'jiggle' instead of sitting there in a nice pile - and because each jiggle adds more collision energy, they tend to jiggle more and more until the pile collapses or cubes at the top of the pile get enough energy to be catapulted into orbit!
So now you say things like "if the amount of interpenetration is "small" then we'll ignore it and not bother with restoring forces. But then you get problems like objects refusing to slide down slopes - so you have to tweak these ugly constants to try to compromise between "jello", "free energy" and "super-stiction".
Another thing that helps (although it doesn't FIX anything - it mitigates the worst effect) is to iterate your physics code at higher rates than things like graphics and audio - perhaps 120 times a second. But the math involved in doing this physics stuff consumes a LOT of CPU time - and doing physics on tiny time-steps means that you don't have enough CPU time left to do anything else!
The compromises that are forced on such systems are truly nasty to resolve. I believe that producing physics software that's robust (ie no objects catapulted into orbit or stuck), 'stiff' (ie no jello cubes), efficient (ie it runs in ~5 milliseconds for (say) 1000 objects), easy to use (no special 'tweaking') is the hardest job in game development. I'd go out on a limb and say that the best minds the industry has have NOT solved the problem to an adequate degree. People ALWAYS spend time kludging the physics code at the end of the project! (And I'm a game developer - I know these things!)
This problem I've explained - is just one of a dozen similarly annoying issues. Floating point math precision is another one, use of real-world data values for things like friction-versus-sticktion is another (especially for car simulation where the behavior of rubber tires is notoriously nothing like the physics text books say they are!)....even the best commercial physics engines are temperamental to deal with - they often require all sorts of 'fake' springs and dampers to be introduced into seemingly correctly described systems in order to make them behave.
If you are passionate - I suggest you download the OpenSourced 'Bullet physics engine. It's free - and you get full source code - and there is a developer community that's friendly enough that you can ask dumb questions and they'll patiently explain stuff to you. SteveBaker (talk) 01:50, 12 March 2009 (UTC)[reply]
This is the sort of answer that keeps me coming back to the RefDesk! Wow. --Scray (talk) 15:47, 14 March 2009 (UTC) [reply]

Hot pixels and Photoshop CS3[edit]

I have a question for all the photography savvy wikipedians (I know you are out there.) I have a Canon XTi and just recently noticed a hot pixel showing up in the jpeg output. I know there are photoshop tools to manage this, and that a Canon service center can map out bad pixels to negate them, and I am weighing my options. However, I opened the RAW version of a shot with a very obvious hot pixel into the RAW import tool in Adobe Photoshop CS3, and unless I am going crazy I am convinced that it automatically erased the hot pixel immediately upon opening it up. I thought I was seeing things so I tried another with an obvious hot pixel in the jpeg version, and once I opened it in the Adobe tool and zoomed into the spot, it was completely gone! Now, the question is, does it do this with some knowledge from camera (an onboard hot pixel detector of some sort) that gets passed in with the RAW file, or is it a sort of noise reduction algorithm that can spot an obvious hot pixel in the image through some method like seeing a raw value of 255,0,0 (for a hot red pixel) in a sea of mostly 136,96,7 pixels (brownish background color)? --Jmeden2000 (talk) 15:36, 9 March 2009 (UTC)[reply]

Maybe the RAW file is quite OK and it's the camera's JPEG algorithm (or possibly just the camera's LCD panel) that is faulty? Astronaut (talk) 18:07, 9 March 2009 (UTC)[reply]
My raw processor, Bibble, has automatic hot pixel detection (by some statistical method, not specific knowledge of hot pixel locations). It wouldn't surprise me if Photoshop/ACR had something similar. I also think dcraw lets you provide a list of known-bad pixel locations. -- Coneslayer (talk) 18:11, 9 March 2009 (UTC)[reply]
A quick Google for adobe raw hot pixels suggests that yes, it's built into the RAW converter. I doubt the camera does any of the detection. — Matt Eason (Talk &#149; Contribs) 21:39, 9 March 2009 (UTC)[reply]
Thanks for the feedback, everyone. I guess I was hoping to find out what methods are actually employed and if they were documented *ANYWHERE* besides internet forums. There are apparently two ways hot pixels will "disappear" in a modern digital workflow. Using the "manual sensor clean" function on newer Canon cameras apparently instigates a feature that can identify and squelch hot pixels from ever re-appearing. This is totally undocumented but observed by many (including myself). Then, in Adobe Camera Raw there is a "simple heuristic" that will forcibly remove hot pixels from a RAW image. I say forcibly because there is apparently no way to turn this feature off. The problem then becomes what happens when this bit of mathematical magic oversteps its boundary, such as in stellar photography where little brightly colored dots are the norm? From one forum, a poster noted: "I have not seen any stars mapped out in [Adobe Camera Raw]!". Duh, of course you haven't! --Jmeden2000 (talk) 20:57, 10 March 2009 (UTC)[reply]
It's pretty easy to detect in RAW mode because the camera's optical system is unlikely to be able to natually produce a single bright pixel without some kind of fuzzy blur around it on adjacent pixel - hence any single pixel anomaly pretty much has to be a faulty sensor pixel. However, it is in the very nature of the JPEG compression algorithm that it's not able to produce a single pixel bright spot because the image compression tricks will cause some disruption of adjacent pixels. Even if you have a single bad pixel, JPEG will store it as a fuzzy blob - which could easily be a natural feature of your photograph and not a fault at all. Hence you can't unambiguously discover if a bright (fuzzy) dot in a JPEG image is a bad pixel or not. That presumably explains why they don't remove artifacts automatically in JPEG...but they do in RAW where the risk of misidentification is almost zero. SteveBaker (talk) 01:15, 12 March 2009 (UTC)[reply]

Mac/G4 question[edit]

Can I plug a new Epson scanner with a USB 2.0 into a 500 MHz Power PC G4 Mac port? Will it run slower or not at all? Or incompatible? Or do I need to change the port internally ? Trav Bickle (talk) 15:42, 9 March 2009 (UTC)[reply]

It'll either work from the pre-installed drivers or you'll need to install drivers for it. Here (http://www.epson.com/cgi-bin/Store/support/SupportIndex.jsp) is a starting point, you click through to your product and it'll have the drivers you need. It should work exactly the same as through a windows machine provided it is has a supporting driver. ny156uk (talk) 16:50, 9 March 2009 (UTC)[reply]
What matters is if there are PowerPC drivers for the Mac OSX version you are using. The USB number does not matter — if you use it with 2.0, it should work faster, but if it is just 1.0, it will probably still work to some degree. But check the scanner specifications. --98.217.14.211 (talk) 02:27, 11 March 2009 (UTC)[reply]

Equipment found in a DNA Lab[edit]

I am trying to find out what the machine that vigorously shakes small vials is called. They have one on the show CSI (Crime Scene Investigation) They use it to shake up DNA samples or unknown substances before putting the sample into another machine that analyzes the sample. I don't want to know what the analytical machine is called. I want to know what the technical term for the shaker is. And where can I get one? ( this is not as important as knowing what the machine is called) —Preceding unsigned comment added by Dunvegangroup (talkcontribs) 18:08, 9 March 2009 (UTC)[reply]

Would that be a Vortex mixer? --NorwegianBlue talk 19:09, 9 March 2009 (UTC)[reply]
A vortex mixer mixes by spinning the tube. I would think maybe a microplate mixer would fit the bill?

http://www.scientificindustries.com/pdf/download-microplate-flyer.pdf Livewireo (talk) 20:58, 9 March 2009 (UTC)[reply]

The OP said the samples were in vials, not in microplates, hence a vortex mixer. --NorwegianBlue talk 21:25, 9 March 2009 (UTC)[reply]
This would be an excellent Q for the Science Desk. StuRat (talk) 23:05, 9 March 2009 (UTC)[reply]
If you type "laboratory shaking machine" into Google, you will get many different kinds of machines that are designed to shake flasks, bottles, and vials. Both the vortex mixer and microplate mixer will be in the list. -- kainaw 23:12, 9 March 2009 (UTC)[reply]
Dunno about shaking small vials in labs, but there is a standard machine called a paint shaker that you can get in hardware stores. It is intended for use mixing colors of paints--you put colored paints in a can and let this thing shake the can for a while. They are sometimes used for low-rent electronic assembly testing (you build your electronic gizmo, then shake it with the paint shaker for a while, then see if it still works). One type of lab stirring device that I've seen (different from Vortex mixer) is a magnetic stirrer: you drop a slug containing a bar magnet into your flask of liquid, and set it on the stirrer base. The stirrer base has a motor that spins an attached magnet, and the magnetic field goes through the flask bottom and makes the immersed slug spin and stir the liquid. 207.241.239.70 (talk) 00:50, 11 March 2009 (UTC)[reply]
(I've actually done that myself - you don't really need any expensive gear. Take two magnets - drop one into a bottle and clamp the other into the chuck of a regular power drill, put it onto it's slowest speed setting and stick it up close to the bottom of the bottle...it worked just fine on the couple of times I've used it!) SteveBaker (talk) 01:07, 12 March 2009 (UTC)[reply]

Firefox login window disappears and reappears[edit]

hey guys im having a problem with firefox when a login window pops up it will disappear after a second or two and then reappear after about 10 seconds is there a way to fix this it never did this in firefox 2 its just really annoying me now so is there a way to fix this?--Quickroom1 (talk) 18:31, 9 March 2009 (UTC)[reply]

Is this on a website? If so what website? —Preceding unsigned comment added by 82.43.88.87 (talk) 19:30, 9 March 2009 (UTC)[reply]
its on any website where a popup comes up asking for your username and password, such as this for example. works fine in ie7 but not in firefox!--Quickroom1 (talk) 21:09, 9 March 2009 (UTC)[reply]
Don't have any idea what the problem is, but I have Firefox 3.0.7 (which I assume you are using) and the login box behaves just fine for me on your example website. It may be a setting issue, and if so, can probably be fixed by a reinstall.Nkot (talk) 23:02, 9 March 2009 (UTC)[reply]

Auto-complete function[edit]

These are rather trivial questions and I should be able to find the answers myself, but anyway: my library login screen has two fields, "Enter your Vancouver Public Library barcode:" and "Enter your PIN:". I see no reason why my computer shouldn't be doing this for me, being as how I'm immensely lazy. Questions:

  • Windows (XP SP3) starts off offering to remember passwords and I long ago told it to quit. Now I can't figure out how to turn it back on to see if it will fill those boxes in. Does anyone know where this is done?
  • Google shows a yellow field for the PIN number, indicating that it would auto-fill, if I chose to turn on auto-fill. I'd like to 1) get Google to recognize the barcode field, since it's a 14-digit number; and 2) figure out what and how it recognizes to make the bold assertion that it can remember my PIN. I don't see any recognition rules in any of the auto-fill options.

If there are simple answers for these, please just point me to where I should have RTFM'ed. Thanks! Franamax (talk) 21:20, 9 March 2009 (UTC)[reply]

You need to explain what web browser you are using. Windows XP is not a web browser. Do you mean Internet Explorer? Google is not a web browser. Do you mean Chrome? -- kainaw 21:23, 9 March 2009 (UTC)[reply]
From what I remember, Google Toolbar highlights auto-completeable fields in yellow, so OP is probably referring to that. That would narrow the browsers down to IE and Firefox. In IE: [1]. In Firefox: Tools > Options > Security > Remember passwords for sites — Matt Eason (Talk &#149; Contribs) 21:46, 9 March 2009 (UTC)[reply]
Oh yes, ha - I thought the default would be assumed, especially when I noted my laziness. :) IE7 (7.0.5730.11) - the standard browser that comes with XP, + updates; and the Google toolbar add-in GoogleToolbar3.dll v. 4.0.1601.4978 which loads to IE (I've suppressed toolbar updates on my FW, so it will be a little OOD).
Matt, thanks for the first link - that was the brain-gap I suspected, I was checking Control Panel rather than the browser settings. D-o-hh!
However, IE7 form completion doesn't seem to work either (though two days and two power cycles often do the trick for Windows config changes, so we'll see). If anyone has tips on how to tweak the Google toolbar completion rules to include that "barcode" text, or however else the hypertext is picked out to spot the fillable box, still most appreciated! Franamax (talk) 03:21, 10 March 2009 (UTC)[reply]

Bit Torrent[edit]

I just went to BitTorrent.com and downloaded BitTorrent. I've just started playing around with it. Can anyone tell me where my completed files will go when they have finished downloading.91.111.86.221 (talk) 22:50, 9 March 2009 (UTC)[reply]

Chances are you are using Windows. If so, chances are the files will either end up in My Documents or on the desktop. -- kainaw 23:01, 9 March 2009 (UTC)[reply]
It's been a while since I switched over to uTorrent, but you can set the preferences to your liking (a temp folder while d/l - and a completed folder where the file gets moved to when completed). By default - I would look at what the settings are now, they be a folder in your "My Documents" or a folder in the Program Files\BitTorrent. (look for keywords like: Settings, Options, Preferences, Tools, etc.) — Ched ~ (yes?) 00:40, 10 March 2009 (UTC)[reply]