Graphics Reference
In-Depth Information
Chapter 12
A2Dand3D
Transformation Library
for Graphics
12.1 Introduction
The ideas of the previous chapters can be nicely condensed into an
implementation—a collection of cooperating classes that help to maintain the
point/vector distinction, the distinction between a transformation T that acts on
points and the associated transformations of vectors and covectors, and some of
the other routine computations that are often done in graphics.
This chapter can be regarded as an instance of the Implementation principle:
that if you understand a mathematical idea well enough, you can implement it in
code, and thereafter be insulated from the need for further understanding.
The topic's website has such an implementation in C#, starting with the pre-
defined Point , Vector , Point3D , and Vector3D WPF classes that you've already
seen. You should download the implementation and look at it as you read this
chapter.
The implementation depends on a matrix library—one capable of invert-
ing matrices, solving linear systems, multiplying matrices, etc. We've chosen to
import the MathNet.Numerics.LinearAlgebra library [Mat], but if you prefer
another one, it should be easy to substitute, as our use of the library is highly
localized.
In most of the classes there are procedures that can fail under certain cir-
cumstances. For instance, if you ask for a linear transformation that sends v 1
to w 1
= 0 , and also sends v 1 to 2 w 1 , there is no satisfactory answer. All such
failures amount to some matrix being noninvertible. We raise exceptions in these
situations. They are discussed in the code and its documentation, but not in this
chapter.
287
 
 
 
Search WWH ::




Custom Search