Wednesday, February 25, 2009

Creating an eBay product turntable

Something I have been pondering for a while is a (free) way of creating a rotating product view on eBay. Some professional sellers do it so I knew it was possible. A bit of research today on wiki.panotools.org led me to a way of using a freeware .jar in an applet to do exactly that.

I reused an empty CD spindle box as a turntable (the transparent top makes a nice reflective surface with a depression that a CD can sit in to form a small Lazy Susan). I then took 8 photographs of a mug I could list on eBay and got my first example up within around an hour of messing about. Hopefully now I know how to use Photoshop to create a strip of photos and automate corrections, the next one will be a lot faster. In particular I have a load of matchbox cars to sell and as they are only worth a couple of quid each I needed a fast way of listing them.

Example turntable (16 photographs):







Needs java.

Turntable (use mouse to stop/drag to turn)

Monday, February 16, 2009

Still waiting for my next gadget to be released

The economic downturn has made electronics companies draw back from releasing new technology. Here are the key gadgets that I would gladly layout good dosh for but don't think they'll exist in 2009:

Better camera specification
  • Must - built in GPS to tag photo location in EXIF
  • Must - 5x or more optical zoom with internal lens
  • Must - pocket sized
  • Must - image stabilization
  • Must - good in low light conditions
  • Must - take decent video of unlimited length (> SXGA @ 30 fps)
  • Must - have excellent burst mode (> 7 shots/s)
  • Must - under £250
  • Nice - waterproof
  • Nice - integrated with mobile
  • Nice - can sync with external flash
Better notepad specification
  • Must - web tablet touch screen
  • Must - screen larger than 10cm wide (iPod Touch is less than 9cm)
  • Must - screen resolution > SXGA
  • Must - wifi
  • Must - GPS so I can find my way on foot or by bus
  • Must - less than £200 (otherwise I'll just get a netbook)
  • Must - take standard memory cards (like SD or M2)
  • Must - takes open source software
  • Must - weigh less than 500g with charger (my laptop weights 1.2 kg and it's a drag)
  • Nice - expanding keyboard 3/4 size or more
  • Nice - built in cheap (£2/month) wireless broadband deal

Better usb drive specification
  • Must - 32GB of storage space (I have 19GB of photographs to carry around)
  • Must - small (preferably tiny) with intrinsic plug cover
  • Must - under £30
  • Could be - a M2 memory card with adaptor (so it can be used in a mobile phone)

Thursday, February 5, 2009

Second Life hexagonal prism space station


Reusing the modules from my tetrahedron experiment, I fairly easily put together a script to create a hexagonal prism of any size. Again debugging the intelligent floor tiles to automatically detect if they are the floor was a real pain due to the lack of an easy way to compare rotations (rather than vectors).

The one generated in the snapshot is of size 3. The square walls are 30mx30m and the longest floor width is 60m. Total prim count = (walls) 6x3x3 + (roof and floor) 2x6x9 = 162.

Update: I had been using my Sony laptop to work with Second Life. With hubby away I borrowed his PC (I'm normally on a Macmini) and was surprised to find the way SL rendered quite different. In particular the equilateral panels I had been using were set with "glow" at 1.0 (maximum) which made little difference on the laptop but on the desktop were mind bogglingly glowing with green radioactive light. Obviously the laptop graphics doesn't render the glow at all. I ended up muting the glow down to zero as they look pretty bright with the "full light" option on (which makes them ignore local lighting conditions).

Wednesday, February 4, 2009

Second Life Tetrahedron maker


Finally debugged the LSL script to generate tetrahedrons of any size using equilateral triangular panels of edge size 10m. In the picture you can see my avatar inside a tetrahedron of size 2 next to one of size 3 and I'm inside a massive tetrahedron of size 7 in the shot below.

The last formula to work out (which I'd fudged a number for before) was the distance between the avatar (or generating object) and the centre of the tetrahedron side. This is actually N*10m/sqrt(24) where N is the size of tetrahedron.

It took a little while to get the side on the bottom to detect itself and texture itself with grass rather than being glass when rezzed. My problem was that llVecDist() which I was using to compare the rotation of a panel to the vector rotation I was looking for (<pi,0,0> or <3*pi/2,0,pi>) was ignoring the fact these are angles and so I had to get the sign right (so the last vector had -pi in the z-axis rather than pi).

All those glass panels make for a classy looking instant space station at 4,000m.

Now I have the subroutines to create equilateral platforms of any size I might try a future experiment using them to make something like a truncated cubic honeycomb.

Now to do some proper work!

Second Life creation problems with equilateral triangles

In Second Life you can create any 3D object using the basic building blocks (called Prims from primatives) like cubes and spheres. These are a maximum size of 10x10x10m (unless you are a God I guess).

I wanted to create the maximum size possible equilateral triangle (in order to help make a giant tetrahedron), unfortunately the "prism" prim was less that 10m on a side maximum. Instead I flattened a 10m cube and tapered it to be a triangle. To turn it into an equilateral I changed the height from 10m to 8.66m, as using Pythagoras' theorem the height must be:
√(102-52)m=√(25x(3-1))m=5m√(2)
≈8.660m


Now here's the unexpected problem. When you rotate the large equilateral, it turns out that the centre of gravity is still based on the cube and so has been set to be at half the height. Consequently to rotate correctly about a centre I had to add a correction vector (unfortunately it's not possible to reassign the centre of gravity of a prim).



The centre of an equilateral triangle can be found by bisecting the angles, the resulting 3 central lines intersect at the centre. Looking at the intersection of one of these bisecting lines and the height line gives a right-angled triangle with 30° at the corner and with a base of 5m. Consequently the distance from the base to the centre of gravity must be:
COG=5m*tan(30°)
=5m/(√3)
≈2.887m


So my correction factor to move to the centre (in the Y-plane) is:
CF=[(5m√2)/2]-[5m/(√3)]
=5m(1/√2-1/√3)

≈0.649m


I kind of wish I'd stuck to the prism prim as this correction factor has really sullied the beauty of my LSL scripts ;)

Sunday, February 1, 2009

Second Life mathematics

About a year or so ago I played around with Second Life but found it was limited as an environment due to lack of integration with IM or Skype (I was looking to use it as an intuitive conferencing tool). It still lacks these features but I've had a little fun recently playing around with the scripting language to play with polygons using Second Life as my geometry lab.

The maximum object size (normally) you can create is a 10x10x10m cube. You can reshape this up in different ways (like a cylinder) but with the premise of making a simple house/room I created a couple of scripts to make giant cubes and domes using a 10x10x0.025m panel as a building block.

My recent experiment was to create a script to use these flat panels to make an N-sided polygon shaped wall in a ring around my avatar. The only tricky bit of math is the distance between the centre point (my avatar) and the 10m wide panel.

This formula does the trick:
distance = panelwidth (2×tan[π/N])
You can work this out by thinking about the right-angled triangle between the avatar, middle of the panel and the edge where the next panel joins:
  1. The base of the triangle shown must be ½ the panel width
  2. the angle "a" cuts up the circle into 2xN triangles (a full circle is 2π in radians) and so "a" = 2π/2N = π/N.
  3. Basic trigonometry gives us the tangent of "a" equal to the opposite side (which we know) over the adjacent side (which is the distance we want).
Programming bit: Note that SL limits the distance you can create (rez) an object to 10m, so my script creates the panel in a small size near the avatar (llRezObject) with the right final rotation, orders the panel (the panel has its own script listening for this command) to the target position (llSetPos) and then the panel resizes itself (llSetScale) when it realizes it has reached the target position (llGetPos). Phew.