Windows 8 beat my Mac

I encountered a very interesting usability issue this evening. A coworkers son completed a school video project in Premier on his Mac, but had to turn in the video in .wmv format. Premier doesn’t appear to be able to do this. That’s interesting (and I have my doubts) but I don’t have Premier to try it myself.

I felt confident I could take his .mov and use some program to convert it on my end. So problem #1 was how to get a 300 MB file to me that didn’t involve driving for an hour. Dropbox? No, he doesn’t use it. Google Drive? Same problem.

I was faced with walking him through setting up a Dropbox account (which is a bit invasive if you choose to use the client) or a Google account (to use a Google service I don’t have any experience with myself).

Ok, what about good old FTP? Well, he hadn’t done that before, but I was optimistic that OS X had some built-in FTP capabilities. It does (hit Command-K in a Finder window) but you can’t upload like that – only browse and download! Woof, big OS X fail there. Furthermore, the FTP server I was trying to use (the one at my day job) was not having a good time.

Fortunately I had installed and configured VSFTPD on my Digital Ocean server a while back, so I started that up and made him an account. I had him download FileZilla, which was fairly painless except for some very scammy click-bait ads on the SourceForge site. No, SourceForge, nobody wants to use your download manager. Ever.

Alight, so he’s all set uploading that file and I have 30 minutes until it’s done to find a conversion solution.

I’ve thrown out the possibility of using any of the scammy looking free converters. What about VLC? Well, it looked like it could do it, but the closest I could pull off was a .asf file. What about iMovie? Nope, no .wmv export option that I can see (which was a bit optimistic of me). I do have a very old copy of Sony Vegas on a Windows 7 boot drive in my closet, but it’s so old that I don’t think it supported wide aspect ratios (and I recall exporting to .wmv producing insanely large files unless you spent a long time noodling with the settings).

So I did the usual pace around and stare off into space muttering to myself thing that typically produces results (and gets me worried glances from coworkers) and thought of something.

I installed Windows 8 a few months ago, just to see what all the fuss is about. I remembered that the ads had some kind of video making program, so I did a Bing search (I’m playing ball today Microsoft) and managed to install the Windows 8 Movie Maker.

The Windows 8 Movie Maker opened the .mov, and saved right out to .wmv. No fussing, no noodling with settings, no nothing but good results.

Windows 8 beat my Mac in built-in functionality. How about that.

 

Posted in Uncategorized | Leave a comment

Project Euler 14 Complete

Project Euler Problem 14 was quick to bang out: https://github.com/cheydrick/Project-Euler/blob/master/ProjectEuler14.c

Problem 15 is intimidating.

Posted in Programming | Leave a comment

Project Euler 13 Complete

I finished up my solution to Project Euler 13https://github.com/cheydrick/Project-Euler

This one was easy to work out on paper, but irritating to implement. It’s pretty brute force, and I read a few solutions in the problem’s forum (which you get access to after you solve the problem) that are much more elegant.

It would have been faster to start from scratch. My half-done program from 2012 had two subtle problems that I (hopefully!) wouldn’t have re-created. The first was screwing up how to index an array, and the second was that I mistakenly thought it was 50 numbers instead of 100.

On to #14!

Posted in Programming | Leave a comment

Books in 2014

I’m going to try to keep track of the books I read in 2014.

So far in the first 16 days of 2014 I’ve read The Twelve by Justin Cronin, and Island in the Sea of Time by S.M. Stirling.

The Twelve is the sequel to The Passage. Both were fairly enjoyable post-apocalyptic reads. I’m looking forward to the third book that should come out this year.

Island in the Sea of Time is an alternative history novel that has a few sequels and I think several other books were written in the same universe. I might pick up the sequel if I stumble across it, but I’m hesitant to get sucked into reading a large collection from one author (again).

Posted in Uncategorized | Leave a comment

Project Euler 12 complete

With the exception of one cosmetic change, I didn’t make any progress in the Project Euler problem set at all in 2013.

I solved Problem 12 a while ago, but never brought it into the project as a whole, so this morning I did just that: https://github.com/cheydrick/Project-Euler

I’m about half-way through solving Problem 13 (and I think I can quickly do Problem 14).

Posted in Programming | Leave a comment

VGA Mandelbrot Set

I read Masters of Doom a few weeks ago, and it inspired me to do some old-school DOS VGA graphics programming.

VGAMandelbrot

https://github.com/cheydrick/VGA-Mandelbrot

When I was a kid I played around with some sample programs that came with DJGPP or Borland C or Turbo Pascal that did various interesting things with VGA graphics, but beyond modifying the routines slightly to see the effects I never truly understood what exactly was happening.

There’s a fantastic VGA programming tutorial here: http://www.brackeen.com/vga/. Big thanks to David Brackeen for writing that.

I managed to get Borland C installed in DOSBox using this tutorial: http://borlandc.org/how-to-install-borland-c-on-windows-8-avoiding-application-cant-run-on-your-pc-contact-with-your-software-publisher/

Unfortunately there are not a lot of good DOS programming resources that are easily searchable. I’d really like to figure out how to read keypresses. David’s tutorial covers registering mouse activity, but I can’t find anything for the keyboard.

Posted in Programming | Leave a comment

Converting Pixel Coordinates to Graph Coordinates Redux

A year ago I wrote a post about converting screen pixel coordinates to graph coordinates: https://chrisheydrick.com/2012/11/01/converting-pixel-coordinates-to-graph-coordinates/

This is something you want to do if you need to map the location of a pixel to an arbitrary graph coordinate, which I needed to do to plot the Mandelbrot set, or plot a sine wave, and so on.

Unfortunately I made a mistake in that post which makes things appear to work, but doesn’t actually work at all (it mirrors the graph). Here is what I’m hoping is the right way to do it. There’s a big TL;DR at the end that lays out the formula and the rules, if you want to skip down to there.

The general form is correct:

Graph Location = Pixel Location * (Graph Width / Pixel Width) + Graph Minimum

However, what you consider to be “Graph Minimum” is a matter of perspective. Let’s try this on a mock image.

graph

Here is an example of an image that’s 320 pixels horizontally, and 200 pixels vertically. Remember that you count pixels starting at the top left. I want to treat this image as if it represents a graph, and I’ll represent pixel and graph coordinates as a pair of X and Y values like this: (X,Y). The center of the image is going to be graph coordinates (0,0), and the graph extends one graph unit positive and negative horizontally and vertically. So, we can see visually that pixel location (0,0), which is at the top left of the image, is graph location (-1,1). Pixel location (319,200), which is at the bottom right of the image, is graph location (1,-1).

graphextremes

Great, so we can see this visually, but we want to calculate it in a program. Let’s do it the wrong way, the way I described it in the other post, first. How about pixel location 0 on the X axis first?

Horizontal Pixel Location = 0

Horizontal Graph Width = 2 (since the graph spans from -1 to 1 for a total of two graph units across)

Horizontal Pixel Width = 320

Horizontal Graph Minimum = -1

Horizontal Graph Location = 0 * (2 / 320) + -1 = -1

Alright, this makes sense. The X-axis pixel 0 corresponds to graph location -1. We can visually see that. Now let’s try to calculate the graph location of the Y-axis pixel 0.

Vertical Pixel Location = 0

Vertical Graph Width = 2 (since the graph spans from -1 to 1 for a total of two graph units across)

Vertical Pixel Width = 200

Vertical Graph Minimum = -1

Vertical Graph Location = 0 * (2 / 200) + -1 = -1

So here’s the problem! We can see that it SHOULD be +1 on the graph, but it’s not.

Where I went wrong was thinking that Graph Minimum should be the minimum value that we can visually see on the axis. -1 is smaller than +1, so -1 is the minimum. What you really need to do is consider Graph Minimum to be the value that can be represented by the minimum pixel value on the screen. X Pixel 0 is at graph value -1, and Y Pixel 0 is at graph value +1. So coincidentally the X Pixel calculation above worked out since the graph minimum is -1 and the graph value represented by the minimum X pixel is -1. The Y value didn’t work out because the graph value represented by the minimum pixel is +1, but the graph minimum is -1.

So here’s big reveal #1: Consider the graph minimum to be the values of the graph at the pixel location (0,0). Consider the graph maximum to be the values of the graph at the max pixel location, which in this example is pixel location (320,200).

And here’s big reveal #2: The graph width is the graph minimum subtracted from the graph maximum. To make this clear, here’s the revised formula.

Graph Location = Pixel Location * ((Graph Maximum – Graph Minimum) / Pixel Width) + Graph Minimum

Obviously plugging in a +1 in the formula above would fix it, so lets try a different pixel location, this time at the bottom right of the image, starting with X pixel location 320. Remember, the X-axis graph value at X pixel 0 is -1, and the X-axis graph value at X pixel 320 is +1.

Horizontal Pixel Location = 320

Horizontal Graph Width = 2 (because (1 – -1 = 2))

Horizontal Pixel Width = 320

Horizontal Graph Minimum = -1

Horizontal Graph Location = 320 * (2 / 320) + -1 = 1

Ok good. The X-axis pixel 320 (which is the far right of the X-axis) corresponds to graph location 1. We can visually see that. Now let’s try to calculate the graph location of the Y-axis pixel 200.

Vertical Pixel Location = 200

Vertical Graph Width = -2 (because Y-axis min is +1, and Y-axis max is -1, and the width is calculated by (graph max – graph min), and (-1 – 1 = -2))

Vertical Pixel Width = 200

Vertical Graph Minimum = 1 (THIS IS +1 NOW BECAUSE IT’S THE VALUE OF THE GRAPH AT THE MINIMUM Y PIXEL VALUE)

Vertical Graph Location = 200 * (2 / 200) + 1 = -1

I’m not sure how clearly I’ve been able to spell this out.

TL;DR, the formula is:

Graph Location = Pixel Location * ((Graph Maximum – Graph Minimum) / Pixel Width) + Graph Minimum

Pixel Location is the location (pixel location) of the pixel on the respective axis, Graph Minimum is the graph value of the lowest pixel value (0), Graph Minimum is the graph value of the highest pixel value, and Pixel Width is the number of pixels on that axis.

TL;DR Example: if we have an image of resolution (320,200), and we consider that image to represent a graph with (0,0) in the center that expands +1 and -1 on both the X and Y axis, what graph value is represented by the pixel location (240,50) which I’ve marked in red?

graphTLDR

We now know that the X Graph Minimum is -1 because that’s the Graph X value a X Pixel 0, and we know that the Y Graph Minimum is +1 because that’s the Graph Y value at Y Pixel 0.

We now know that the X Graph Maximum is +1 because that’s the Graph X value at X pixel 320, and we know that the Y Graph Maximum is -1 because that’s the Graph Y value at Y Pixel 200.

X Graph Location =240 * ((1 – -1) / 320) + -1 = .5

Y Graph Location = 50 * ((-1 – 1) / 200) + 1 = .5

So the graph location at pixel (240,50) is (.5, .5), which looks right to me!

Posted in Programming | Leave a comment