Main Categories: | Landscape | Fenceposts | Wildlife | Trees | Mushrooms | Art | Games || All Posts ||
for daily images, visit my ||Tumblr||
Showing posts with label tech. Show all posts
Showing posts with label tech. Show all posts

Tuesday, 4 March 2014

Spirals

I wrote a while back about how elegant spirals can be in computer games - in particular, they are useful if you want to iteratively cover a space with evenly distributed points, with the range expanding out from a single starting location and with one growing tip - I have used them in the past for searching for a suitable placement point in a landscape for a game object, but I'm sure there are many other applications.


Anyway, I didn't include any code in that post, so here below is a Spiral function that is ready to use. This is written in C# for Unity, but should be easy enough to convert to whatever you happen to be using.

Vector3 Spiral( float dist, float spacing ) {
float rad = Mathf.Sqrt(  dist / (Mathf.PI*spacing ));
float angle = Mathf.PI * 2.0f * rad;
 
Vector3 retVal = Vector3.zero;
retVal.x = spacing * rad * Mathf.Sin( angle );
retVal.z = spacing * rad * Mathf.Cos( angle );
return retVal;
}



'dist' is the distance along the line of the spiral from the origin, and 'spacing' is how far apart you want the coils of the spiral to be from each other (this spiral has the handy attribute of maintaining a constant radial distance between each concentric coil.)

To achieve an even distribution of points, increment the distance param by the value of spacing - that way points will be equally distant form their neighbours on the line as they are from the neighbouring coils.

Here is a screen shot of the points generated by calling Spiral( dist, 1.0f ) with dist = [0,1,2,3...] As you can see, the unit spheres are packed pretty close to 1 unit apart:



Changing the spacing to 2.0f and iterating Spiral( dist, 2.0f) with  dist = [0,2,4,6,8...] will lead to each of the unit spheres having 1 unit's space between them:



...Spirals!



Tuesday, 27 March 2012

MyBook access from Linux

I just spent most of an evening trying to access my Western Digital MyBook Live net drive from a machine running Debian Linux. Got there eventually, so if I write out the steps that worked, it might save someone a few headaches:

You will need to apt-get install nfs-common and portmap - this is the networking file system drivers - you may well have them already. So, as root:


apt-get install nfs-common portmap


Then, still as a super user run:

showmount -e 192.168.0.2(use the ip address of your MyBook)

This should return a couple of lines of text something like this:


Export list for 192.168.0.2:
/nfs *

The first term on the second line is telling you the mount point you need to access to get at the files on the netdrive, so next - still as root - type:
mount (ipAddr):(2nd line of showmount response) (your chosen mount point)
eg:
mount 192.168.0.2:/nfs /mnt/mybook

Now you should be able to access the public folders on the network drive by navigating to /mnt/mybook in the file manager, terminal, etc.

If this worked, you can then mount the net drive at startup by editing the file /etc/fstab (need to be super user to do this)
add a line like the following:
(ip-addr):(2nd line of showmount response) (your chosen mount point) nfs defaults 0 0
eg:
192.168.0.2:/nfs /mnt/mybook nfs defaults 0 0

And that should be you done! I need to figure out how to access the private shares next, but that is for another day... :-P

Wednesday, 9 February 2011

MP2 to MP3 converter

Just a quick tech note to anyone with MP2 files that they want to convert into MP3s:

You can get freeware/shareware converter utilities to do it, but if you have iTunes already, simply put the MP2 files in an iTunes play list Right Click (or Ctrl Click) on them to open the contextual menu and choose 'Create MP3 Version' job done!

It will put the newly created MP3s in the same place it saves new music imported from CDs - usually the 'iTunes Music' folder.