O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Work with Vectors

Problem

You need to perform calculations with three-dimensional vectors.

Solution

Create your own simple vector class.

Discussion

The .NET Framework does not include any built-in support for vector calculations. However, it’s quite easy to create a class to represent vectors. This class will include methods such as Add, Subtract, Multiply, and DivideBy, and well as a few vector-specific functions such as GetCrossProduct and GetDotProduct. In addition, the class will support cloning and comparing (useful for sorting arrays of vectors), and it will override the Equals method to perform value equality testing and ToString to provide an appropriate string representation. Chapter 4 provides recipes that allow you to implement these refinements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required