-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy path5-1-ConvertToHomogeneous.pg
More file actions
93 lines (76 loc) · 2.24 KB
/
5-1-ConvertToHomogeneous.pg
File metadata and controls
93 lines (76 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
## DESCRIPTION
## Converting points and vectors to homogeneous coordinates
## ENDDESCRIPTION
## DBsubject(Geometry)
## DBchapter(Vector geometry)
## DBsection(Coordinate systems)
## Date(02/02/2018)
## Institution(Bentley University)
## Author(Nathan Carter)
## TitleText1('Introduction to the Mathematics of Computer Graphics')
## AuthorText1('Nathan Carter')
## EditionText1('1')
## Section1('5')
## Problem1('1')
## KEYWORDS('homogeneous coordinates')
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
);
Context("Matrix");
$showPartialCorrectAnswers = 1;
@r = (
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
non_zero_random(-10,10),
);
$ans1 = Matrix( [
[ $r[0] ],
[ $r[1] ],
[ 1 ]
] );
$ans2 = Matrix( [
[ $r[2] ],
[ $r[3] ],
[ 0 ]
] );
$ans3 = Matrix( [
[ $r[4] ],
[ $r[5] ],
[ $r[6] ],
[ 1 ]
] );
$ans4 = Matrix( [
[ $r[7] ],
[ $r[8] ],
[ $r[9] ],
[ 0 ]
] );
TEXT(beginproblem());
BEGIN_PGML
Express [`([$r[0]],[$r[1]])`] in homogeneous coordinates.
[_____]*{$ans1} [@ helpLink("matrices") @]*
Express [`\langle [$r[2]],[$r[3]] \rangle`] in homogeneous coordinates.
[_____]*{$ans2} [@ helpLink("matrices") @]*
Express [`([$r[4]],[$r[5]],[$r[6]])`] in homogeneous coordinates.
[_____]*{$ans3} [@ helpLink("matrices") @]*
Express [`\langle [$r[7]],[$r[8]],[$r[9]] \rangle`] in homogeneous coordinates.
[_____]*{$ans4} [@ helpLink("matrices") @]*
END_PGML
BEGIN_PGML_SOLUTION
A point [`(x,y)`] in homogeneous coordinates is the column vector [`\left[\begin{array}{c} x \\ y \\ 1 \end{array}\right]`].
A vector [`\langle x,y \rangle`] in homogeneous coordinates is the column vector [`\left[\begin{array}{c} x \\ y \\ 0 \end{array}\right]`].
A point [`(x,y,z)`] in homogeneous coordinates is the column vector [`\left[\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right]`].
A vector [`\langle x,y,z \rangle`] in homogeneous coordinates is the column vector [`\left[\begin{array}{c} x \\ y \\ z \\ 0 \end{array}\right]`].
END_PGML_SOLUTION
ENDDOCUMENT();