Michael Quandt

UTS MSP

Scalars & Vectors

clock December 24, 2008 21:45 by author

Please note that I will first explain what each concept is, and then I will write up how to calculate/get each concept afterwards.

A scalar is simply another name for a number, however it uses that name to indicate a difference between a Vector and a single number. (Or other mathematical structures)

In the field of game programming, Vectors play a key role in almost every aspect. In its simplest form, a Vector is a collection of 2 or more scalars that indicate a point in space, relative to the Origin [3D=(0,0,0) | 2D=(0,0)]. Each scalar in a Vector is called a component, and indicates the distance along the corresponding axis from the origin. For example, the Vector (9,5) is 9 units along the X axis, and 5 units along the Y axis. Vectors can be used to indicate positions, directions, and many other things. It all depends on the context, and what the Vector is relative to. (World/Local space)

Vectors in pure maths generally refer to a direction rather than a point, however in computer graphics we use Vector structures to represent a point. We can view a point as the end of a direction from the origin, however when written, points usually are written with parenthesis (0,0) and Vectors are usually written either using angle brackets <0,0> or in component form, where each part (component) of the Vector exists as the coefficient of a unit vector pointing along the corresponding axis. [More on Unit Vectors later]

For example, the Vector <9,5> can also be written as 9x + 5y.

The accepted way of indicating something is a Vector in digital form (as opposed to written on paper) is to bold the vector, for example i.

So now that you are most likely confused, let us move on to Unit Vectors. A Unit Vector is a vector with a distance of 1. This is the way you represent an axis in Vector form. For example, the unit vector for the X axis in 3D space is <1,0,0>. You can see that in our component form, the scalar co-efficient of x is 9, which is the distance along the X axis.

Key to getting the Unit Vector, is a concept called Magnitude. This is represented by two bars on each side of the vector. The magnitude of the vector is a scalar representation of the distance from the origin, so if  you need to find the distance of a Vector from the origin, you are simply calculating the Magnitude.

The magnitude is found by applying the distance equation between the Vector and the Origin. The distance between two vectors is found by taking the square root of the squares of the difference between the corresponding components. Quite a mouthful, isn’t it?

To find this in code, we use the following:

public double Distance(Vector3 i, Vector3 j)
{
    double x, y, z;
    
    x = Math.Pow((i.X - j.X), 2);
    y = Math.Pow((i.Y - j.Y), 2);
    z = Math.Pow((i.Z - j.Z), 2);
    
    return result = Math.Sqrt(x + y + z);
}

In Mathematical notation, this is just:

Distance Function

So for magnitude, where we are getting the distance between the Vector and the origin, we are subtracting 0 from each component, which simplifies the equation down to:

clip_image002[13]

So now how do we use the result of this to find the unit vector? Well the equation for a unit vector is clip_image002[15]. This pretty much means that we divide each component of our vector by the magnitude of the vector. This is what we do to “normalise” a vector, and this allows us to multiply the vector by a number and not change its direction.

Remember that Vectors are a way of representing many things, although the common definition is that they represent a direction combined with a magnitude, which we can use to get a point, as if we moved the point from the origin along the direction using the magnitude. It is all about context, and that determines how you use the vector and its components. For example, a normal is a vector which indicates the direction perpendicular to the object’s tangent. (A tangent is a vector parallel to the line/object)

Another calculation common in computer graphics that uses Vectors is the Dot Product. This is a multiplication of two vectors which gives a scalar value that can indicate many things, usually though it can be used to get the angle between two vectors. The dot product is rather simple, you multiply each component of a vector with the corresponding component in the 2nd vector, and then add the result of each of these multiplications together to get a scalar value.

Dot Product

We can use this and:

Angle to Dot

to find the angle between the two vectors. After rearranging we use

Dot To Angle

(Note that the cos is simply ArcCos)

I hope this has explained what a Vector is and some key aspects about it, if you have any further questions leave a comment. Comments and criticism welcome. I plan to write another post on Matrices, with a focus on their application in computer graphics.

If I have missed anything, just tell me in a comment and I will add it in a later post, this was written after a nice lunch on Christmas day, and I am a bit tired now.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Moving Servers

clock November 3, 2008 02:53 by author

I am currently in the process of working with my webhost to move my site over to their new platform. The benefits of this means I can use subdomains properly (I think) and they promise me that I will be on the Windows Server 2008 platform, which means IIS7. :) (That lets me use things like the URL rewrite module)

Due to the inspirational talk by Scott Hanselman at TechEd Sydney 2008 I am also considering using Asp.Net MVC to create a new blogging/content platform to replace BlogEngine.net on this website. Currently BlogEngine.net is serving me well, however I do like to write my own, and I would prefer to bake in a good page system rather than adding to a token implementation on a blogging platform.

More info once I make the move, and once I get started on the project. Might even make a small screencast or write a tutorial on it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Dreamspark out in AU

clock September 7, 2008 04:33 by author

So TechED Sydney is over and I now have the time to post about the big announcement for students that came out of the event. On Tuesday Microsoft held TechEd Student Day, a free day for students to come along and sit in on a series of presentations geared towards students, TechEd style.

Aside from that, every University student who attended the University half of the day received 4 DVDs full of free software, ready for use. Now if you could not attend this event, do not fret, this is all available for you as well (if you are a student), however you need to download it for yourself.

Head to https://downloads.channel8.msdn.com/ and Sign In with your Windows Live ID, and then verify your student status and you can get your keys and downloads for all the software listed. This includes:

  • Visual Studio 2008 Pro
  • Visual Studio 2005 Pro
  • Windows Server 2003 Standard
  • SQL Server 2005 Developer Edition
  • Microsoft Expression Studio
  • 12 Month XNA Creators Club Trial
  • XNA Game Studio 2.0
  • Virtual PC 2007 (Great for use with Windows Server 2003)

Grab the downloads, grab the keys, and start making cool things with this free software. Anything you make can be distributed with a non-commercial license, so get to it!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Visual Studio 2008 SP1 Released

clock August 11, 2008 16:29 by author
Visual Studio 2008

Microsoft has just released the long-awaited SP1 update to Visual Studio 2008 and .Net 3.5 after being in beta for a number of months.

Download it here

SP1 brings loads of enhancements and features to both Visual Studio and .Net 3.5, including a major performance (20%-45%) boost for WPF, the ADO Entity Framework, and full support for the newly released SQL Server 2008.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Havok Physics and Animation Now Free!

clock June 1, 2008 13:49 by author

havok_logo_CMYK For those doing native application development that need a Physics or Animation product, Havok, partnered with Intel have released the world famous Havok Physics & Animation package for free.

This gives you the complete binary for use in your personal, educational or even commercial game as long as it is below US$10.

Currently there does not seem to be anything for XNA (despite an apparent job ad a while back), but I am sure this will be wrapped soon enough, and then the power of Havok will be available for use on the PC platform in XNA as well.

You can get Havok from http://tryhavok.intel.com. Just fill out the form and download the Programmer binaries and Artist tools.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Big MSP Event #1

clock May 25, 2008 02:41 by author

I have been a Microsoft Student Partner since the beginning of this year, and in conjunction with the other MSP at UTS,(Chris Webster) have been planning a large event for this semester.

Recently we decided that the best thing to do was to give a talk on the ways you can get free (or cheap) software from Microsoft as a student.

The time has finally arrived.

How to get Free (and cheap) stuff from Microsoft

Slides and content will be available after the presentation, although probably only late night or next day due to a late lecture. :P

If you intend to come to the event, head to the website there and register your interest so we can get an idea of numbers.

Remember, not only do you take away the methods of gaining free software, but you also take away a bag of goodies and have the chance of winning a lucky door prize!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Australian Game Exports on the Rise

clock May 19, 2008 06:11 by author

In my preparation for CeBIT starting tomorrow I found an article on the website about the recent export numbers for Australian Game Developers.

http://www.ausinnovate.com/2008/05/05/export-boom-for-game-makers/

The article mentions that 06-07 data shows $139.7 million in generated revenue, with most of the market coming from Queensland or Victoria. Programmers accounting for 29% of those employed, compared to 34% for artists. A logical number. :)

If you missed out on the free registration, check for information next year around February, that is the time the free Registration occurs.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Digital Tutors: Maya + XNA

clock May 16, 2008 01:21 by author

The professional video tutorial scene has started to adopt XNA from the looks of it, with Digital Tutors releasing a DVD training package named Pipeline Development with Maya and XNA.

Popular highlights:

  • XNA Development Overview
  • Interfacing with Keyboard and Gamepad
  • Building Controller Systems
  • Controller Vibration
  • Exporting and Loading Static Meshes from Maya
  • Exporting Animated Characters from Maya
  • Moving and Turning a Character
  • Object-oriented Programming with Bullets and Targets
  • Baking Textures in Maya
  • Deriving Bounding Boxes from Maya
  • Collision Detection with Bounding boxes
  • Collision Detection with Rays
  • Building a Custom Animation Player
  • Switching and Blending Between Animations
  • Chase Cameras
  • Camera Shakes
  • Drawing Text
  •  

    CGSociety has this to say about the product:

    'Pipeline Development with Maya and XNA' contains nearly five hours of project-based training for technical artists learning the methods of creating game content using XNA and Maya. 'Pipeline Development with Maya and XNA' offers artists an essential workflow and innovative techniques for easily integrating Maya and XNA for game creation.

    Since this costs money, I cannot get this at the moment and so I cannot give my own review. However it looks like a good product, and considering Digital Tutor's track record, it should be a good investment for the artistic programmers out there.

    Edit [17/5/2008]: I noticed that Digital Tutors also has an interesting looking Training Package titled Real-Time Shaders with XNA.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    XNA 3.0 CTP Available

    clock May 7, 2008 06:34 by author

    As of now the XNA 3.0 Community Technology Preview is available for download.

    XNA 3.0 CTP

    This requires a version of Visual Studio 2008 and will co-exist with Visual Studio 2005 and XNA GS 2.0.

    Note there is no Xbox360 support in the CTP release, however there will be with the final release, currently only PC and Zune.

    Now I am off to see what else they added. :) Enjoy.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Demos Happen Here

    clock April 9, 2008 03:29 by author

    HHH tab To help celebrate the launch of Visual Studio 2008, Microsoft is holding a competition that is open to all.

    To win some really awesome prizes, you just need to create and submit a 10 minute or less video demo of one of the new technologies being launched. So that could be C#3.0 or LINQ, or anything else related to the products launched at the Heroes Happen Here 2008 launch event.

    The comp runs from the beginning of April (it's started!) until September, and is open to everyone.

    You can get more details as well as a registration form at http://www.microsoft.com/australia/heroes/community.aspx.

    It is pretty simple, just create a small demo, put it online using Silverlight Streaming, complete the registration form and send it in.

    If you are a part of a group you have a higher chance of making the national finals because 3 demos from at least 2 people in a group (User group etc) will go through, whilst only 30 random demos will be chosen by Microsoft if they are alone.

    So find some other people making demos, choose your best and send them off!

    If you win in the national finals, you get a Media Center PC, a trip to Tech Ed 2009 in LA, and a copy of Visual Studio 2008 Team Suite, WITH a MSDN Premium subscription! All for a 10 minute demo.

    (There seems to be issues with the website at the time of writing, but I have assurances it will be resolved ASAP)

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Gamercard

    About the author

    Michael Quandt is a Student at the University of Technology Sydney. He is also a Microsoft Student Partner. Passions include DirectX, Managed Code, C#, XNA, and gaming.

    Page List

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

    © Copyright 2008

    Sign in