Hawkeye: 3D visualisation and modelling with ICT Preface

A week or so ago I circulated some ideas about using pairs of synchronised video clips from different views of the same object in motion to recreate its 3D space-time coordinates and to be able to plot its trajectory as a space curve. The context there was that I have recently become interested in some of the experimental techniques used in sports science, particularly biomechanics, and wanted to see if some of the ideas could be made accessible to interested students and teachers without all the expensive hardware and software usually connected with it!

Thanks to helpful feedback from a number of recipients I have brushed up the ideas into the form of an article, and taken the opportunity both to correct an error and to add some material on 3D vector geometry. In the first case I had made an error in my choice of the viewing plane in assuming it would contain the “world” z-axis – which would only be true if the view point V was in the ground plane. For greater generality the viewing plane should be perpendicular to OV. Looking at some standard texts on computer graphics (including my own “Geometry with Microcomputers”) the standard approach to perspective geometry is based on using successively a number of matrices to rotate, scale and project points – in the most general case using 4x4 matrices with homogeneous coordinates! Assuming that most interested readers would have little or no knowledge of matrices or their geometric application I needed to find a different technique. In my original piece I used some similar triangles and trigonometry to compute projections. With the more general position of the viewing plane I needed to find a more appropriate approach.

However the article is not just a technical one offering solutions to a problem which anyone interested should now be able to integrate into their own explorations. There is a pedagogical dimension as well. I wanted to explore a use of CAS assistance in an area of mathematics in which I have never previously used it before: vector geometry. Although 2D vectors are in the KS3/4 curriculum they do not get much attention! The best we can hope for is that students might remember that the journey from A to B as a vector is the same as the journey from A to C and then from C to B: (1) AB = AC + BC. Perhaps also that if a and b are position vectors of A and B then (2) AB = AO + OB = -OA + OB = -a + b = b – a, and that if A, B, C lie on the same straight line then (3) AC = t.AB for some value of t. Maybe a few students will recognise that these work in 3D and 2D? That’s enough for us to find the position vector r of any point R on the line VP as:

(4) r = OR = OV + VR = OV + t.VP = v + t.(p – v) = (1-t).p + t.v - which is pretty well the most useful tool for vector geometry: the vector equation of a line. What remains are tools to help with testing and making things perpendicular. Again, from GCSE coordinate geometry, students should recognise the condition for the 2D vectors a = and b = to be at right angles (aka perpendicular aka orthogonal) – by considering the gradients of OA and OB: xa/ya = -yb/xb, to get (5) xa.xb + ya.yb = 0. So we can probably get away with defining this to be the 2D dot product of vectors a, b and by stating that this extends to the 3D case as well, where the dot product, dotP(a,b), is given by: a.b = xa.xb + ya.yb + za.zb, and that a is perpendicular to b if (and only if) a.b = 0 . (So we don’t need to raise the idea of scalar product as a b cos q.)

This enables us to show that x = is perpendicular to v = . The remaining trick we need is to produce a vector y which is perpendicular to both x and v, and I would be content to say that this is what the function y = crossP(v,x) produces! (We can always check that v.y = 0 = x.y).

I would be as enthusiastic now about slogging through the algebra to arrive at the perspective projection functions xx and yy as I was when I was punished at primary school by copying out longer and longer psalms – and almost certainly less accurate! By applying algebraic results in known geometric situations, like the carousel, we can get immediate visual feedback (Logo style) as to whether or not we are on the right lines.

In pursuing this investigation I used just 3 different software tools: Cabri 3D, Tracker and TI-Nspire. These seem to me to represent possible elements of a basis set of software for science and mathematics experimentation, modelling and problem-solving which should be available to all schools, students and teachers. At the moment I need to add some data-logging software such as Vernier’s Logger Pro, and maybe another geometry tool like Sketchpad, Cabri 2D or Geogebra – we just need Lord Mandelson to invest!!

Hawkeye: 3D visualisation and modelling with ICT

Adrian Oldknow March 2010

1. Introduction

We are now used to having TV and video cameras at major sporting events e.g. to adjudicate contested line calls in tennis or to assist a third umpire in cricket. They permit us to see simulations of how the ball was travelling based on 3D reconstructions of its flight and hence to predict whether or not it would land in court or hit the wicket. In this article we will take a look at some of the mathematical techniques which make this possible. First we will use some ICT tools to establish how to map the 3D coordinates of an object in space onto 2D coordinates of its perspective projection from a viewpoint onto a viewing plane. Then we will use the technique to show how we can obtain visualisations of geometric loci, of algebraic space curves and of 3D scatter plots. These techniques should enable the interested reader to set up and explore 3D models for themselves using appropriate ICT tools. We will start with a 3D geometry tool (Cabri 3D), and a mathematical package containing 2D geometry, graphing, computer algebra, numeric computation and spreadsheets (TI-Nspire) to try to obtain the magic formulae.

2. Setting up the 3D scene

In order to make calculations of positions we need some sort of coordinate system for 3D space. We will start with a common one in which the plane defined by the origin O together with the x- and y-axes forms the “ground floor” – or horizontal plane, and so the z-axis is the line perpendicular to this through O – i.e. the vertical. The conventional way of sorting out positive from negative directions is to use a so-called “right triad” where if, using your right hand, your middle finger points along the positive x-axis (coming towards you), your first finger points up the positive z-axis (upwards) and your thumb points along the positive y-axis (in front of you from left to right). This is the representation which Cabri 3D uses.

Cabri 3D’s starting point is just to give you three short coloured vectors and the shaded ground plane (z = 0). The red and green vectors are in the ground plane and the blue one represents the vertical. We have constructed points X, Y and Z at the ends of the vectors and measured their coordinates, together with the origin O. We have constructed a point (x, y, 0) in the ground plane which can be freely dragged around. Next we have constructed the vertical to the ground plane through (x, y, 0) and constructed a point (x, y, z) on it. This point, together with the origin, defines one diagonal of a cuboid whose vertices are shown.

In order to investigate projective geometry we need to define an object P (xp, yp, zp) to view and a viewpoint V (xv, yv, zv) from which to view. From these we should be able to calculate the position of the projected image point I (xi, yi, zi) in the chosen viewing plane and convert these to 2D coordinates (Xi, Yi) for use in 2D graphing and drawing.

In the figure alongside, a sphere has been constructed with centre O through a point A along the extended x-axis. The point V is taken on the surface of the sphere (hidden), and the diagram shows the actual values of the coordinates (vx, vy, vz), the length r = OA, and the angles q = óNOV and f = óAOS, which correspond to the spherical polar coordinates of V. The vector OV is the perpendicular (also called the “normal”) to the viewing plane through O. This establishes the connection between the 3D “Cartesian” coordinates with which we will be working, and the “spherical polar coordinates” used for example in Google Earth, SatNav and GPS systems. Later we will set up such a system for improved “feel” when manipulating 3D objects on screen.
So, how with just 6 numbers (the 3D coordinates of V and P) can we calculate the 3D and 2D coordinates of the projected image I? Any point X on the viewing x-axis will have 0 for z-coordinate and be such that OX is perpendicular to OV.
We need a few ideas from vector geometry. Two vectors are perpendicular if their “dot product” is zero. In particular the point X (-yv, xv, 0) has zero dot product with V (xv, yv, zv). The “vector product” of two vectors along OV and OX will give a vector along the third axis in the viewing plane shown as OY.

We can find the “vector equation” of any point J on the line VP in the form: J = (1-t)V + tP , and there will be a unique value of t for which J lies in the plane XOY. This is when OJ is perpendicular to OV. So we form the dot product J.V and find the value of t for which this is zero. Substituting this value for t in the equation for J gives the vector I. Then we can consider the viewing plane x-axis. Here the point Q lies on OX so that IQ is perpendicular to OX. We can write OQ = s.OX and use the previous technique to set up and solve a dot product equation for s. Finally we repeat this trick for the viewing y-axis and find R on OX which is such that IR is perpendicular to OX.

Of course the algebra can get pretty messy, so having a CAS system, such as with the Math Boxes on a TI-Nspire Notes page, is a great boon. In the screen below we have a TI-Nspire notes page open on the left and the Cabri 3D geometry page on the right. We copy the values for the vectors v and p, and solve the equation v.((1-t)v + tp) = 0 for t. The value of 1.8 corresponds to the ratio between the lengths VP and VI. The vector i agrees with the coordinates of I, too! We define vector x by copying in the values of –yv, xv and 0. Vector y is defined as the cross product of v and x. For the viewing x-axis we find that OQ = 1.34 OX, and so the 2D X coordinate of I is OQ = 6.7. Repeating this for the viewing y-axis we find that OR = 0.24 OY, so the 2D Y coordinate is OR = 6.4.

Now we can run repeat trials by adjusting V and/or P in the Cabri screen, copying the changes to any independent variables to the TI-Nspire screen, and checking that the 3D and 2D viewing coordinates are computed correctly. Once we are happy that the process (or “algorithm”) is correct then we can go and find algebraic functions which carry out the transformations.

In the first of the algebra screens we set up the general coordinates for the points V and P in the column vectors v and p. We enter the elements for the vector x for the point X on the viewing x-axis so that v.i = 0, and compute the vector y for the point Y on the viewing y-axis as the cross-product of v with i. This ensures we have three mutually perpendicular (“orthogonal”) vectors for the viewing coordinate system. The coordinates for the image point I in the viewing plane are found by solving where the point (1-t)v + tp meets the viewing plane, and so is perpendicular to v. This value of t is substituted in the formula for i to find the coordinates xi, yi and zi as functions of our 6 independent variables xv, yv, xv, xp, yp, zp.

In the second screen we find the values of the parameters s and u which define the projections of I onto the viewing x- and y-axes. In the third screen below these are used to define the projected 2D coordinates xx and yy as functions of the 6 variables.

Now we have just what we wanted:
a pair of functions xx and yy which take the coordinates of the viewpoint V and an object point P and return the X and Y coordinates of the projection of P in the viewing plane.
You could use these functions in other software, such as Excel, to produce perspective views of data and curves, but we will stick with TI-Nspire.

3. Plotting a space curve

Alexander is piloting the black plane which swoops up and down as it goes round and round. Any part of him is tracing out a curve in space. Can you visualise the locus of his left ear?
We will try and model this path both in Cabri 3D (as a trajectory) and in modelling software such as TI-Nspire (as a space curve) – by using parametric functions to define his x-, y- and z- coordinates at any time t.
We start with a point A in the ground plane and construct the circle through A around the vertical z-axis vector. P is any point on this circle. B and C are points taken on the perpendicular to the ground plane through O. The line parallel to the x-axis through B (not shown) is taken as the axis for the circle centre B through A. Q is any point on this circle.
The perpendicular to the ground plane at P is constructed, as is the plane through Q parallel to the ground plane. This plane cuts the vertical through Q at S and the z-axis at R. P and Q can slide independently on their domains (the horizontal and vertical circles). As they do so, S moves on a space curve. P and Q can be made to move around their circles at different speeds using the Animation controller. The resulting trajectory of S can be traced as shown.
To model this algebraically we note that since P is describing a circle in the ground plane, the x- and y-coordinates of S will be of the form:
x = a cos (dt), y = a sin (dt), where a = OA is the radius of the circle and d defines the speed of rotation. Q is also describing a circle, but it is its z-coordinate OR which fixes the z-coordinate of A, and this is given by
z = b + c cos (et), where b = OB, c = BC and e defines the speed of rotation.
On the fourth “CAS” screen we define the functions xe, ye and ze which convert from spherical polar coordinates (r,q, f) to Cartesian coordinates (x, y, z). We also define drawing parameters and function to conform with measurements taken from Cabri 3D.
Now we can plot the architect’s style plan and elevations by plotting each of the three pairs of parametric equation. The plan view is just the circle, and the elevations are known as Lissajous’ figures.
We should now have all we need to get to work with 3D projected displays. The first test is to create a 3D data set from which we will produce a 2D scatter plot. In a spreadsheet we set up a list of values for time t, called tv, as a sequence from 0 to 500 in steps of 5.

We define the lists xcoord, ycoord and zcoord as values for the x, y, z coordinates of points on the aircraft’s flight path calculated from the functions fx(t), fy(t) and fz(t) at each value of t in tv. On a Graph page we have set up sliders by which you can adjust the coordinates of the viewing position V. These set the values of the variables px, py and pz used to convert (xcoord, ycoord, zcoord) into the projected 3D coordinates (xproj, yproj, zproj) and finally the 2D versions (xdat, ydat).