Wikipedia:Reference desk/Archives/Computing/2012 April 18

From Wikipedia, the free encyclopedia
Computing desk
< April 17 << Mar | April | May >> April 19 >
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.


April 18[edit]

Using Chrome[edit]

Wikipedia:User page design center/Help and collaboration/Help requests is not the most heavily looked at page. I only bothered to answer Transclution problem because I couldn't see the problem. It turns out that the problem is only seen when using Chrome. Can anybody help them solve the problem? CambridgeBayWeather (talk) 00:09, 18 April 2012 (UTC)[reply]

The behavior of tables could be explained, but this page really shouldn't be using any at all. Lose the tables and the chances it will work as expected will increase. ¦ Reisio (talk) 00:32, 18 April 2012 (UTC)[reply]

Digital signatures and email[edit]

As I understand it, there is some kind of digital signature and/or certification mechanism available that is designed to allow one to verify that an email did really come from the claimed source. However, I have never knowingly received a digitally signed / certificated email (though I'm not sure how I would know if I did... do I have to "switch it on" somehow?) But does anyone actually ever use this feature? Do companies, like banks for example, ever use it? If not, then why not, given that it is, as I understand it, trivially easy to fake a sender's email address. Wouldn't its use stop all sorts of fraud? 81.159.109.156 (talk) 02:15, 18 April 2012 (UTC)[reply]

It's actually a pretty straightforward tool; and it's fairly easy to set up. For example, on Mac OS X Mail.app, Use personal certificates in Mail. The trouble is, like all other digital certificate problems on the internet, that most people don't understand how trust works. In my mind, this is guided by a very simple rule: "Do not trust a digital certificate unless you trust its source." However, what actually happens in practice is, "trust your computer, which was pre-loaded to trust any digital certificate that is granted by one of a few dozen major corporations or any of the tens-of-thousands of their delegates." As such, most certificates are useless; they guarantee that the grantee was the recipient of a securely signed certificate; and they guarantee that you're securely communicating to the grantee; but they don't really tell you who the grantee is. I only trust a very small number of digital certificates: those that I generate myself; or receive in hard-copy from people I know; or that I receive from the system administrator of an organization I am directly involved with.
Probably the most frustrating thing to me: this misappropriation of "trust" is not exclusive to for-profit corporations. Even "free software" providers like Mozilla Foundation pre-load their email client and web browser to trust anyone who pays them (sorry, my cynicism: for anyone who meets their stringent risk-benefit analysis and public review process. And this has caused problems in the recent past. Nimur (talk) 02:33, 18 April 2012 (UTC)[reply]
Thanks, I thought that a certificate could prove that an email purporting to come from someone@mybank.com actually did come from someone at mybank.com. Is that not right? Is that not a useful thing to know independently of your "trust" concerns? Might I be getting digitally signed emails from mybank.com without actually knowing it, or should something "pop up" to tell me? I use web-based email and I am not aware of any option that makes any reference to this feature. 81.159.109.156 (talk) 02:39, 18 April 2012 (UTC)[reply]
Public key cryptography is the technological basis for modern digital certificates. For it to work, your bank signs its content (web-pages, emails, and so on), using a private key. To decrypt it, (or to guarantee its cryptographic integrity), you must have the reciprocal public key, which needs to come from a trusted source. Where did you get this key? Chances are high that you got it from the website, which used a chain of trust to a root certificate authority, whose public key is already on your computer. Who put that key there? Is it valid? Do you trust it?
It does not need to work this way; you could get your certificate through a secure channel (like, by copying a file in-person, when you show up at your bank). This is a bit of paranoia; almost everyone trusts root certificate authorities, because they usually have fairly reasonable policies and usually are trustworthy. However, as I mentioned above, root certificate authorities have been compromised, validating the paranoia a little bit. In at least one major recent publicized event, a root certificate authority was operated by a malicious group whose express purpose was to convince you that they were the trusted organization you believed they were. The scary part is, the technology part of computer-security worked flawlessly: you were securely communicating to the malicious party. If you were a victim of the DigiNotar debacle, nobody (except the malicious party) could intercept your financial information. Nimur (talk) 03:01, 18 April 2012 (UTC)[reply]
I understand. I think! However, I am still unsure how prevalent, in practice, the use of digital signatures is in email communication from banks and other major companies, and how I tell if an email is digitally signed. For instance, on your system, if you get a digitally signed email, does something "pop up" to tell you, or is there a flag or something? What would be the typical way that one would tell? 81.159.109.156 (talk) 03:07, 18 April 2012 (UTC)[reply]
Yes, you'll have a "User Interface" that shows you when mail is secure, when it's not secure at all, and when it fails to validate securely ("fake" mail). That user-interface depends on how you're securing the mail, and in which client you read your mail. One of the most common ways to encrypt (or sign) a mail message is using the S/MIME standard. If your email client supports S/MIME, you would usually see a user-interface "flag" or "message" indicating the security status. If you use web-mail, your server-provider must do this work for you. As the user, you might not always know what type of software is "driving" the webmail interface; but for example, a lot of webmail providers use the SquirrelMail server software, which can support S/MIME using a plugin (I volunteer no assertions about the security or reliability of this plugin). If you use Mozilla Thunderbird, you can use S/MIME; if you work at the National Center for Supercomputing Applications, you can configure secure email, and the results will look like this - some status and meta-information about each mail. (To first-order, GnuPG is probably a little bit more secure and less friendly than S/MIME).
How prevalent is secure email in the wild? Few of my friends like it when I send them secure mails. (It "looks weird" or "doesn't work," depending on their technical ability). My financial institution does not send me any information via email that I would care to have secured. Out on the internet at large, almost all email is sent in plain-text, which is very scary to me. On the other hand, I have certainly been involved with organizations in which secure computing was an absolute must. Friends of mine who work for government agencies (even "boring" agencies like those that regulate accounting practices for veterinary products) tell me that they typically must use secure computers, including their emails. Nimur (talk) 03:28, 18 April 2012 (UTC)[reply]

IE9 WMP add-on[edit]

Hi, I have asked this question at several forums but I have been totally unable to find an answer, and it's really annoying me. Can anyone here possibly help? In the IE 9 add-ons list I see one instance of Windows Media Player, which is enabled and is set to "run without permission" on any site (I believe this was an installation default since I have not knowingly changed it). Yet, when I go to some websites, I get a message "This website wants to run the following add-on: 'Windows Media Player' from Microsoft Corporation", asking me to OK it. Note that the website wants to run WMP, not install it, which I understand means that it wants to run the version of WMP that is already installed. However, as I say, the (only) installed WMP add-on has permission to run on any site -- so why am I being asked? Second question: is there any possible risk, when I'm prompted with this message, in allowing WMP to run? The message has a "What's the risk?" link, implying that there may be one, but the link just points to a useless page that does not help at all. Can anyone shed any light on any of this? 81.159.109.156 (talk) 02:31, 18 April 2012 (UTC)[reply]

My first suspicion would be site- or domain-specific security preferences. Security Zones for Internet Explorer can override your default preferences with extra-strict security policies. These can be configured or disabled, to satisfy your actual needs and preferences.
Regarding risk: there is always a risk, but in this case, unless you suspect that WMP has an unknown security vulnerability, or if you suspect that your WMP or other parts of your system are already infected with malicious software, it is unlikely that playing a video can cause any serious harm to your system. More information available from the source: Security in Windows Media Player. Nimur (talk) 02:52, 18 April 2012 (UTC)[reply]
Thanks, the sites in question are in the normal "Internet" zone, which has installation default settings throughout. I have not customised any settings, or added sites to the Restricted zone, or anything like that. Everything is just as installed. 81.159.109.156 (talk) 03:03, 18 April 2012 (UTC)[reply]

what is a driver in computing[edit]

what is a driver in computing — Preceding unsigned comment added by 81.153.130.53 (talk) 10:11, 18 April 2012 (UTC)[reply]

Usually people mean device driver, although as Driver#Computing shows, there are several other (related, kinda) drivers. -- Finlay McWalterTalk 10:15, 18 April 2012 (UTC)[reply]

GPS navigation[edit]

Is a GPS navigation device capable of correctly guiding the car at any given coordinates set, particularly from a location in one country to location in another country?--176.241.247.17 (talk) 12:43, 18 April 2012 (UTC)[reply]

Any given coordinates? No. Firstly, many car GPS units don't let you enter a raw GPS coordinate - after all, who knows the full GPS location of their local branch of Aldi? If you just mean any location (say any street address to any other) then probably still no. There are good digital road maps for western european countries and other developed countries like North America, Japan, Korea, Australia, etc. - but poor or non-existent maps for other places (much of Russia, most of Africa). Other countries vary (you get good trunk road maps for some places, but not for narrow little streets in cities). Some countries don't have up-to-date digital maps, others have them but haven't worked out the legal arrangements with digital mapping companies to properly disseminate them. And car satnavs don't try to plot routes from one place to another when they don't have a driving route (New York to Amsterdam, Tokyo to Warsaw) - Google Maps occasionally jokes that you should swim the Atlantic. Commercial satnavs (those intended for lorry drivers) sometimes have better info about ferry schedules, but I don't think they cover more than short-distance scheduled ferries (e.g English Channel). For long distance transoceanic travel one still has to rely on a shipping agent, and driving across Africa or Siberia the satnav won't be much help. But driving from pretty much any address in Western Europe to another, or one address in the US to another, then sure. -- Finlay McWalterTalk 14:00, 18 April 2012 (UTC)[reply]
Just a side note, but my GPS on my iPod can track my location to within a couple of metres - sometimes even within buildings - here in Eastern Europe (Hungary at the moment), and I can plot a route all the way to Calais or Oslo if I want. KägeTorä - (影虎) (TALK) 21:22, 18 April 2012 (UTC)[reply]
I know this is a losing battle, but I want to raise a still small voice of protest against the locution GPS coordinate for latitude and longitude. Latitudes and longitudes were used long before GPS. Hope it doesn't make me sound old that I know that. --Trovatore (talk) 08:44, 19 April 2012 (UTC) [reply]
There are a variety of Geographic coordinate systems that go way beyond naive concepts of latitude and longitude: see Datum (geodesy). Since GPS coordinates can be accurate to a small number of meters, you need more than just the old vague latitude/longitude system, and there's a wide range of different systems. --Colapeninsula (talk) 17:17, 19 April 2012 (UTC)[reply]
Sure, but they're still not "GPS coordinates". They're latitude and longitude using the WGS84 datum (usually, though my GPS has an option to pick a different one if you want). --Trovatore (talk) 21:15, 19 April 2012 (UTC)[reply]

Installing linux on a second windows partition[edit]

I have a computer with Windows XP and two ntfs partitions (C and D). I would like to install linux on the second (D) partition without breaking windows. As far as I can see the important windows directories/files are all on C. However I am not sure about the following directories which are on D: "D:\Desktop" and "D:\Documents". Do these have any special meaning in windows? "C:\Documents and Settings" is on C as are "C:\Documents and Settings\Administrator\Desktop" and "D:\Documents and Settings\All Users\Desktop". Can I just install linux on D, or do I first have to tell windows that I am going to take that partition for linux? I understand that all files on D will be lost when installing and that Windows won't be able to see that partition as it is going to be ext3. bamse (talk) 13:27, 18 April 2012 (UTC)[reply]

It sounds like those folders aren't specifically known to windows - but to be sure, rename them to OLDdesktop etc. and make sure everything to need on windows (after a restart) still works okay. Linux won't install into an NTFS partition (heck, maybe it will, but you don't want it to) - typically you'd destroy that partition (personally I'd do that with the Windows partition editing thingy) and Linux will create its own partititions in the free space that destroying that leaves over. Or you can install a virtualisation solution like VmWare or VirtualBox and install the linux into that (that's a safe thing to do). -- Finlay McWalterTalk 13:36, 18 April 2012 (UTC)[reply]
Thanks. Will move stuff from D to C as you suggest and see what happens. If everything works fine, will install linux in D, destroying everything there with the linux partitioning tool (during installation). bamse (talk) 13:51, 18 April 2012 (UTC)[reply]
No, I mean rename d:\Desktop to d:\oldDesktop and reboot and make sure everything still works.
Be extra-super careful when deleting a partition that you've really deleting the one. Partitions have unfamiliar names when viewed in the raw partition editor, and plenty of people who know better (myself included) have either erased the wrong partition or have inadvertently copied a blank partition over a good one. Without a backup (which you so have to do) there's no way back from that. -- Finlay McWalterTalk 14:18, 18 April 2012 (UTC)[reply]
What's the difference between renaming it or moving it to another destination? Will be extra careful when deleting. bamse (talk) 14:38, 18 April 2012 (UTC)[reply]
Also, in the linux partitioner, I have one primary partition (#5) marked with "B" (for boot) and one logical partition (#2). Can I assume that the primary boot partition corresponds to C: in windows? Or how can I find out which partition corresponds to which windows letter (C/D)? bamse (talk) 15:11, 18 April 2012 (UTC)[reply]


How many GB of free space do you have on D:? I have an ubuntu installation with a humongous number of programs installed and the system takes only 11GB. (excluding the data files that you create and save in your linux home folder) If you are only playing with/testing linux and have a large partition then maybe you could just resize (not delete) the partition (so your windows data can still be stored on D:) and free the last 15GB or so. Do this from windows if you can (win vista and above) or if win<=XP use the linux partition editor to resize. This space on will comfortably hold an ubuntu install with a moderate number of programs and ~7GB of data on a 14GB ext4 partition and a ~1GB swap partition. Good luck. Staticd (talk) 15:46, 18 April 2012 (UTC)[reply]
Thanks for all the replies. I picked the correct partition it seems. bamse (talk) 21:32, 18 April 2012 (UTC)[reply]

Printing emails[edit]

My wife frequently receives emails with hundreds of 'To' addresses. She needs to have the email printed, but does not need the multitude of addresses, how to I eliminate those before printing to save paper please? I'm using "Apple Mac "Mail". — Preceding unsigned comment added by 85.211.216.235 (talk) 13:31, 18 April 2012 (UTC)[reply]

Apparently Mail doesn't allow you to do this of itself. In my opinion, the easiest way would be to Copy paste the text into your favourite Word processor, then print from there. This discussion from Apple Support contains a few other alternatives, including using the Print Selection utility. - Cucumber Mike (talk) 17:40, 18 April 2012 (UTC)[reply]
Another option, if the text is only a single page, is to scroll the addressee list off the screen, so only the text is visible, and do a print screen from there. (I'm not familiar with Apple, so don't know if they have an option to do a print screen directly, or if, like Windows, that only copies the screen into a buffer, from which you must paste it into another application, and then print from there.) StuRat (talk) 18:10, 18 April 2012 (UTC)[reply]
You could run a grep filter on a large text file. Since you're on the mac grep's already available to you. However, figuring out what regex to use is not a simple task if you're new to it. Shadowjams (talk) 19:50, 18 April 2012 (UTC)[reply]

Got the message, thanks. — Preceding unsigned comment added by 85.211.216.235 (talk) 06:42, 19 April 2012 (UTC)[reply]

Resolved

New Netbook[edit]

I am in Hungary presently, and have acquired a netbook, which I was thinking of giving to my mother as a present when I get back to the UK this weekend, as the last nebook I gave her has stopped working correctly. However, the OS (Win7) is entirely in Hungarian, which my mother has no knowledge of, plus the keyboard is a Hungarian keyboard, so I have decided to keep it for myself, as she has to look at the keyboard when she types and would find it frustrating. I would, however, like to change the OS to UK English. How can I do this, if it possible? On a related note, I downloaded Firefox for it, and ended up with the Afrikaans version by accident. Is there any way to change the language without redownloading Firefox? Cheers. KägeTorä - (影虎) (TALK) 13:34, 18 April 2012 (UTC)[reply]

I think of only two ways (choose only one):
1) buy English version of Win7 and install it on netbook (you'll also need an external USB-connected DVD drive). Also you'll need to download the corresponding drivers for different parts of hardware from the netbook's manufacturer website and install them.
2) Buy an upgrade to Win 7 Ultimate (costly, upgrading from Starter edition will cost you £140.00) (you can do this online on Microsoft website http://emea.microsoftstore.com/UK/en-GB/Microsoft/Windows/Windows-7/Windows-Anytime-Upgrade ), then in Update Center in Win7 control panel you can download any language you want. You don't need to reinstall Windows in this case. 109.173.37.164 (talk) 22:19, 18 April 2012 (UTC)[reply]
Strange! My parents swapped their windows settings from english to another language and I was under the impression they didn't have W7 Ultimate.. But you're right, the sources I have found say you need W7 ultimate to use language packs.. I'll have to do a bit of poking around. Vespine (talk) 00:29, 19 April 2012 (UTC)[reply]

Ask in a computer store (any). The staff are very knowledgeable and have loads of foreigners buying computers who can't read Hungarian - it's probably their best market! It would not be an unusual question/request at all, and I've heard other patrons ask it. Usually the answe is that, besides not being able to change the physical plastic keyboard, changing the language the OS uses is possible. But like I say, just ask. --80.99.254.208 (talk) 09:02, 19 April 2012 (UTC)[reply]

Thanks for the replies. I was sure it was possible, as I have changed my Vista laptop (which I no longer use much, as I have a different laptop now that has Win7 Home) to Japanese. Looks like I might have to use my Win7 Home (UK) to look at the settings, then just click on the same settings (eg. third line from bottom, etc.) and hope for the best as the netbook also uses Win7 Home, because my Hungarian is not good enough (yet) for a computer. I have changed the IME to EN, so input is not a problem for me as I touch-type, but my mother can't do that. Anyway, cheers! KägeTorä - (影虎) (TALK) 08:00, 20 April 2012 (UTC)[reply]

Appending excecutable to Command Prompt[edit]

I would like to append an excecutable so when I type it at first looks like a command, I know it can be done because perl behaves like that, unluckily when I installed python, It didn't "appended" to the cmd, so how to do it manually? (Or "programmably") 190.60.93.218 (talk) 14:02, 18 April 2012 (UTC)[reply]

I'm having a real hard time understanding what you want to do here. "append an excecutable so when I type it at first looks like a command" doesn't make any sense to me. Are you asking, "how can I make it so that if I type in the name of an executable (e.g. "python" for "python.exe") into the command prompt, it runs no matter what directory I am in?" If so, that's just adding the path of the executable to the [path environmental variable] ("Path"). This page explains how to do it in Windows. If that isn't what you are trying to do, please explain it a little more carefully. --Mr.98 (talk) 14:12, 18 April 2012 (UTC)[reply]
I'm sorry for your struggle..(I don't speak English natively.) Yes, that's what I need. Thanks. 190.60.93.218 (talk) 14:18, 18 April 2012 (UTC)[reply]
If I remember correctly, the Windows CPython installer sets pythonw.exe up as the handler for .py files, so trying to execute one of them should automatically invoke the python runtime. I don't think %PATH% need be involved at all. -- Finlay McWalterTalk 14:34, 18 April 2012 (UTC)[reply]
Slight correction, per this: .py invokes python.exe (with a visible text window) and .pyw invokes pythonw.exe (without a visible text window). -- Finlay McWalterTalk 14:35, 18 April 2012 (UTC)[reply]
Actually no.. You see.. "Commands" on cmd like ping, pathping, makecab, msg, chkdsk, find, format etc.. are located in the same folder as cmd.exe, So I can understand why typing their names (without the exe extension or %). But perl.exe is not in that directory, typing "perl" it works in any folder... It's not an enviromental variable (it is?) because I don't have to type %perl%. Just perl. What I want is to do the same with python. (So when I type python at the start of the cmd. It 'opens' it, independently of the current folder. 190.60.93.218 (talk) 14:38, 18 April 2012 (UTC)[reply]
Yes, that webpage think it has it! thanks. 190.60.93.218 (talk) 14:42, 18 April 2012 (UTC) PS:Ignore previous comment.[reply]
What you want to do is: 1. find the python executable, 2. Add it to the "Path" (%PATH%) variable. If you do that, then typing in the python variable in the command prompt from any directory will call it correctly, if that is what you want it to do. --Mr.98 (talk) 14:53, 18 April 2012 (UTC)[reply]
Yes that's what I wanted to do. I never knew why %path% was so long, I have unexisting folders in %path%, now that I know how it works I think I can clean it up a bit.. Yes, added C:/python32/ to path, and worked. Thanks! 190.60.93.218 (talk) 14:58, 18 April 2012 (UTC)[reply]

how hard is 2.5 d[edit]

without any graphics acceleration if I can only draw 2d in my window, and only know 2d graphics, how hard is it for me to fake a perspective: for example, to have documents on a wall you (the camera or point of view) are a fixed length and angle from (such that I generate the documents and then skew them with an algorithm). No movement other than a whole document at a time. is this 'hard'? no 3d graphics experience, and I would be rolling it all myself without any acceleration, for a very very low-end generic windows and crossplatform (2d) target. 188.6.94.248 (talk) 18:07, 18 April 2012 (UTC)[reply]

What you want is an 3D projection, which is relatively easy to implement (although even for a pretty good programmer a couple of days is more reasonable than a couple of hours), but to make it work smoothly on a low-end platform without acceleration would probably be quite difficult. Looie496 (talk) 21:11, 18 April 2012 (UTC)[reply]
And 3D_projection#Perspective_projection has the math formulae. StuRat (talk) 21:23, 18 April 2012 (UTC)[reply]
Well, as graphics go, that's relatively straightforward, involving a bit of trigonometry (sines and cosines). Far simpler that rendering a parametric surface, for example. However, beware that small text will not be very readable while the docs are floating by. Large titles should be, though. Also beware that you will need a high frame rate to keep it from looking "jumpy", since you are dealing with rather small objects (letters). Therefore, you might want to consider lowering the resolution during movement, such as replacing small text with a box or lines. StuRat (talk) 18:15, 18 April 2012 (UTC)[reply]
Do you have any experience with this? It sounds like you can be very helpful. I'm confused about what you were referring to by "floating by" since I specified that the POV would be fixed, so that rather than movement, you get a sudden new view (like a page-down without smooths crolling, or switching tabs). The camera or point of view (i.e. person/you) are not allowed to move in any direction. A click on the wall brings the unskewed doc into foreground. Does this sound like it can be done all in 2d with no acceleration and very quickly? Let's be explicit. If I give you a bitmap 600x200 how would you skew it so that it is hanging centerd on a plane at distance of 1000 picture-widths from you and 30 degrees above the horizion.

Ascii art:

in:
xxx
xxx
xxx

out: one of the sides facing the street in the buildings here: http://jhh.blogs.com/anthos/images/perspective_1.jpg you see how the sides facing inside toward the street are skewed? Because they're at an angle (you are not looking at them dead-on, with parallel rays from the surface). I want the same skew effect algorithmically done myself. Will this take me more than a couple of hours to figure out? --80.99.254.208 (talk) 19:41, 18 April 2012 (UTC)[reply]

I'm confused by your completely different IP address. Are you the original poster ? If so, then yes, that sounds doable, but a couple hours seems perhaps low. I'd say more like 8 hours. One confusing thing, though, is that 1000 picture widths distance. At that distance, the document would be a very small box, or even a pixel (imagine a 1 foot long document viewed from 1000 feet away). My own experience is more with isometric views than perspective views, but I could probably still help. The most difficult thing in the perspective view you gave would be the hidden line removal, but that doesn't sound like it applies, in your case, since nothing is hidden. BTW, what language are you using ? I'm a FORTRAN programmer myself, so would it be of any help if I made a FORTRAN example ? StuRat (talk) 20:12, 18 April 2012 (UTC)[reply]
Hi, sorry, yes same OP here (both the IP's in this thread so far are me, I don't know if it's changed again). First of all, yes an example would help tremendously. I made a mistake when saying "1000 picture-widths", I meant that I did not really specify the units when I said a "a bitmap 600x200" (I didn't say pixels) and I meant, 5 times as far away from you as as the picture is wide. I think by picture-widths I meant "picture-width-units". Sorry. The best language for me is Python, but I also can follow C++, Java, etc. 188.6.94.248 (talk) 12:56, 19 April 2012 (UTC)[reply]
OK, today's a bit busy, but I will see if I can work on an example Friday or Saturday. It will be in FORTRAN, but hopefully you can read that well enough to get the idea. What size, in pixels, do you envision the doc, once in the perspective view, and what's the total screen size you want ? StuRat (talk) 16:43, 19 April 2012 (UTC)[reply]
Hi, Stu, thanks for taking this on. It doesn't really matter, does it, as for your specific questions? They can be variables
screenwidth = 800px
screenheight = 600px
distance-from-wall = 2000px (the camera is 2000 px from the vertical wall)
docwidth = 400px (width of doc on wall)
docheight = 400px (height of doc on wall)
doccenterheightaboveground = 1000px (eye level)
cameraheightaboveground = 1000px (eye level)
angle-to-center-of-doc-azimuth = 0 (not looking left or right)
angle-to-center-of-doc-altitude = 0 (not looking up or down).
if the program were written in terms of these particular variables, then I could move by varying the last three of them, couldn't I? Fast drawing is not needed as this would be rendered once and shown. The actual document would be a 400x400pixel bitmap file (in this case). My question is how we skew it into view. --80.99.254.208 (talk) 19:18, 19 April 2012 (UTC)[reply]
OK, I'm going to simplify the math as much as possible in the code, both to make it quicker and simpler to understand. One last thing we should discuss is the color depth. Do these documents have 1-bit color (black and white), 24-bit color, or something in-between ? (Fewer bits, of course, means quicker rendering.) Also, can I assume that there is a single background color, as opposed to watermarks, patterns and such ? (A single background color will produce better results.) And, can I assume that each letter has a single foreground color, as opposed to gradations in shading ? (Again, this will produce better results.) StuRat (talk) 06:31, 20 April 2012 (UTC)[reply]
Hi Stui, since I'm trying to understand the math, any 2-bit, no-good bitmap 'document' should be fine. Likewise sure you can assume anything about the background or anything else you need, since I'm going to try to be understanding your algorithm and probably also convert it into another language. Thank you for anything like this that you may be able to put together, or otherwise for any pseudocode about approximately what you would do. --188.6.94.248 (talk) 15:59, 20 April 2012 (UTC)[reply]
You sure you mean 2-bit ? That's 4 colors, while 1-bit is 2 colors. StuRat (talk) 16:05, 20 April 2012 (UTC)[reply]
I was actually trying to make a pun (two-bit, no-good, double-crossing...) It can be just black and white, if I see the skewing algorithm I will be able to treat other kinds of pixels I assuem... Thanks for any help. 188.6.94.248 (talk) 17:32, 20 April 2012 (UTC)[reply]
OK, I get it now. I've started on the program, and will finish up, right after I get a shave and a haircut with your two bits. :-) StuRat (talk) 22:53, 20 April 2012 (UTC) [reply]
I should mention why I'm concerned about background color versus foreground color. Imagine that the input pic consists of a series of horizontal lines, each one pixel thick. As the far edge of the skewed output pic approaches the vanishing point, each line should get thinner. However, if they started out as 1 pixel thick, how can they get any thinner than that ? I've found, if I do nothing to prevent it, the result is that the line becomes dashed, then progressively more dotted. To me, this looks bad.
A fancy way to handle this might be to make the line stay 1 pixel thick, but become closer to the background color. But, I want to keep this example simple, so, I'm using a quick fix, instead. I keep the line 1 pixel thick, without blending it into the background. To do this, I must be able to distinguish between foreground pixels, which preserve their thickness, and background pixels, which don't. Note that this quick fix does have an undesired consequence, that the skewed pic becomes more "foregroundy" (darker if the foreground color is darker than the background and lighter if the foreground color is light), as we approach the vanishing point. However, I consider this better than dashed or dotted lines. (Note that the horizontal lines were just an example, the reality is that text and everything else becomes dotted.) StuRat (talk) 23:22, 20 April 2012 (UTC)[reply]
OK, here's the relevant subroutine for the code I came up with. It takes about 7.5 milliseconds of real time to run on a 400×400 bitmap with 64 colors per pixel, on my low-end computer (Pentium 4, 2.8GHz, running Windows XP SP3). I used the C convention of arrays numbered 0-399, rather than 1-400, to make it easier to adapt to C, and fully commented it. Take a look and let me know if it makes sense:
     subroutine PERSPECTIVE_VIEW (IN_ARY
    +                            ,INVARIANT_PT
    +                            ,V_SHRINK_R
    +                            ,V_SHRINK_L
    +                            ,H_SHRINK_T
    +                            ,H_SHRINK_B
    +                            ,BGD_COLOR
    +                              ,OUT_ARY)
     implicit   none
  • Inputs:
     integer*1     IN_ARY(0:399,0:399)  ! INput ArRaY, colors between 0 & 63
     integer*2     INVARIANT_PT(1:2)    ! between (0,0) and (399,399)
     real*4        V_SHRINK_R           ! Vertical   SHRINKage percentage
                                        !  along Right edge
                                        !  (between 0.0% and 100.0%)
     real*4        V_SHRINK_L           ! Vertical   SHRINKage percentage
                                        !  along Left  edge
                                        !  (between 0.0% and 100.0%)
     real*4        H_SHRINK_T           ! Horizontal SHRINKage percentage
                                        !  along Top
                                        !  (between 0.0% and 100.0%)
     real*4        H_SHRINK_B           ! Horizontal SHRINKage percentage
                                        !  along Bottom
                                        !  (between 0.0% and 100.0%)
     integer*1     BGD_COLOR            ! BackGrounD COLOR: 0-63
                                        !                  -1 = unknown
  • Input/output:
  • Outputs:
     integer*1     OUT_ARY(0:399,0:399) ! OUTput ArRaY, colors between 0 & 63
  • Local variables:
     integer*2     X,Y                  ! X and Y counters for IN_ARY
     integer*2     NEW_X,NEW_Y          ! X and Y counters for OUT_ARY
     real*4        V_SHRINK             ! current Vertical   SHRINKage
                                        !  (between 0.0% and 100.0%)
     real*4        V_SHRINK_STEP
     real*4        H_SHRINK             ! current Horizontal SHRINKage 
                                        !  (between 0.0% and 100.0%)
     real*4        H_SHRINK_STEP
     integer*1     C                    ! loop variable for all Colors used
     integer*4     COLOR_COUNT(0:63)    ! number of pixels for this color
     integer*4     MAX                  ! MAX number of pixels for any color
  • If background color is unknown, find it (use the most common color):
     if (BGD_COLOR .eq. -1) then ! ".eq." means "equals"
       do C = 0, 63
         COLOR_COUNT(C) = 0  
       enddo
       do X = 0,399
         do Y = 0,399
           COLOR_COUNT(IN_ARY(X,Y)) = COLOR_COUNT(IN_ARY(X,Y)) + 1
         enddo
       enddo
       MAX = 0 
       do C = 0, 63
         if (COLOR_COUNT(C) .gt. MAX) then ! ".gt." means "greater than"
           MAX       = COLOR_COUNT(C)
           BGD_COLOR = C
         endif  
       enddo
     endif
  • Initialize output array to background color:
     do X = 0,399
       do Y = 0,399
         OUT_ARY(X,Y) = BGD_COLOR
       enddo
     enddo
  • Determine how much the shrinkage percentage changes with each row or column:
     V_SHRINK_STEP = V_SHRINK_L - V_SHRINK_R
     H_SHRINK_STEP = H_SHRINK_T - H_SHRINK_B
  • For each non-background pixel in the input array, determine the shrink
  • percentages, and find the location for that pixel in the output array:
     do X = 0,399
       V_SHRINK                 = V_SHRINK_L - V_SHRINK_STEP*X/399
       do Y = 0,399
         if (IN_ARY(X,Y) .ne. BGD_COLOR) then ! ".ne." means "not equal to"
           H_SHRINK             = H_SHRINK_T - H_SHRINK_STEP*Y/399
           NEW_X                = X - (X-INVARIANT_PT(1))*H_SHRINK/100.0
           NEW_Y                = Y - (Y-INVARIANT_PT(2))*V_SHRINK/100.0
           OUT_ARY(NEW_X,NEW_Y) = IN_ARY(X,Y)
         endif 
       enddo
     enddo
     return
     end
Here are the inputs I provided (besides the bitmap):
     INVARIANT_PT(1) = 199  ! between 0 and 399
     INVARIANT_PT(2) = 199  ! between 0 and 399
     V_SHRINK_R      =  0.0 ! between 0.0 and 100.0
     V_SHRINK_L      = 50.0 ! between 0.0 and 100.0
     H_SHRINK_T      = 30.0 ! between 0.0 and 100.0
     H_SHRINK_B      = 30.0 ! between 0.0 and 100.0 
     BGD_COLOR       = -1   ! between -1 and 63
Here's the image it produced (I just used a red grid to test the code, it should work the same with a document):

Here's the same image, if I don't distinguish between foreground and background pixels:

This would result by commenting out the "if (IN_ARY(X,Y) .ne. BGD_COLOR) then" line, along with the corresponding "endif". As you can see, not projecting background pixels is an important anti-aliasing technique, needed if you want to produce a quality image.
Note that these settings "project" the pic onto the right wall, but by swapping the SHRINK values around you can also create a projection as it would occur on the left wall, floor, or ceiling. (I put "project" in quotation marks, since this isn't really a projection, which would involve all that math, but rather a simulation of a projection. If it doesn't look quite right, try varying the SHRINK values until you get what you want.) Changing the invariant point has the effect of moving the camera/eye.
By varying the SHRINK percentage from less than 100% to more than 100%, we can also create the illusion of projecting on both walls (or both floor and ceiling), right across the vanishing point:

Note that this demonstrates the problem of the pic becoming brighter as it approaches the vanishing point. Here's another version which darkens the pixels near the vanishing point, to compensate for that:

I can provide you with the code to do that, if you like. However, there is another distortion. The vertical lines at the edges appear to be closer together than those near the vanishing point. Hopefully this won't be noticeable in your case. If so, and the far part of the document is stretched too much, I can work on a fix.
You'll note that I didn't do any bounds checking on the projected pixels. I'd normally verify that each pixel is between (0,0) and (399,399), but omitted this check, to speed the code up a bit. As long as the calling program checks that the invariant point is within this range and the SHRINK variables are all between 0 and 100%, this safeguard isn't needed. You could even use SHRINK factors up to 200%, which would result in reversing the image, provided the invariant point is in the exact center (since the exact center of our array is (199.5,199.5), you'd need to either make the invariant point two real numbers, or limit the SHRINK value, to, say 199.5%).
The coordinate system I used looks like this:
+-----------> X
|
|
|
v
Y
If you have the Y pointing up, then you will want to swap the H_SHRINK_T and H_SHRINK_B variables everywhere they occur in the code. Similarly, if you have X pointing to the left, swap V_SHRINK_L and V_SHRINK_R.
In the declarations, "*1" means 1 byte (8 bits), "*2" means 2 bytes, and "*4" means 4 bytes. You can use larger variables, if you like, and the only negative effect will be that it will take up more memory and run slower. However, don't use any smaller variables, as that will cause problems. For the bitmap arrays, I used integer*1, or 8 bits. This supports 256 colors, but I only used 64 colors, numbered 0-63. If you want to extend this to 24 bit color, I'd add another dimension to the input and output arrays, to make each (0:399,0:399,0:2), where the last 3 values are the red, green, and blue values, or HSV color space values, if you prefer.
I'd also like to know if you're able to adapt this code to your needs, and how long it takes.StuRat (talk) 14:57, 21 April 2012 (UTC)[reply]

Javascript regex group to array[edit]

Hi all, given the string

"a:T,b:T,a:m,b:M,a:w,b:W"

I would like to create a simple expression to grab each of the values after "a:" and put them in an array, resulting in

["T", "m", "w"]

The simple regex below almost does this, but it captures the entire matched set, not the inner group.

string.match(/a:(.*?),/g)
  => ["a:T,", "a:m,", "a:w,"]

Is there a simple way to grab the inner group instead, or do I need to loop over ever match and put it in an array myself? Thanks! Sam 63.138.152.219 (talk) 20:21, 18 April 2012 (UTC)[reply]

You'll need a loop, at least if your input is of arbitrary length (regex isn't turning complete, this was explained to me once but the details are lost on me). As for why it's grabbing the whole string, I don't know. It should work. Is it possible that javascript's regex library doesn't support non-greedy? The work-around is not elegant, but it's to use [^,]* instead of .*, which should work. Shadowjams (talk) 22:13, 18 April 2012 (UTC)[reply]
I'm sure I'm doing it wrong..
"a:T,b:T,a:m,b:M,a:w,b:W".match(/a:(.*?),/g).map(function (loop) {
    return loop.match(/(?=:)../).toString()
}).map(function (omg) {
    return omg.match(/[^\:]/).toString()
})
 
//output:>> ["T", "m", "w"]

Anyway.. maybe a regex god will help you.. this is totally not the solution. 190.158.212.204 (talk) 03:06, 19 April 2012 (UTC) PS:Wait a second does the string you want only has numbers and letters?[reply]

Disdain that!
"a:T,b:T,a:m,b:M,a:w,b:W".split(',').filter(function (boo) {
    return /a:.*/.test(boo)
}).map(function (s) {
    return s.match(/[^a:]+/)[0];
})

In this case you could use this code that is even shorter.

"a:T,b:T,a:m,b:M,a:w,b:W".match(/a:([^,])*/g).map(function (short) {
    return short.match(/[^a:]+/)[0]
})
Why do you need this for? 190.158.212.204 (talk) 04:12, 19 April 2012 (UTC)[reply]