Modern vector notation (the dot product, the cross product) was developed independently by Josiah Willard Gibbs and Oliver Heaviside in the 1880s, partly as a simpler rival to quaternions.Gibbs and Wilson, Vector Analysis, 1901; Heaviside, Electromagnetic Theory, 1893
The six exercises of the old vector labs as functions: march along a line, lay out a segment, build a plane, test which side of it a point is on, drop a shadow onto it, cut a segment with it and reflect the direction, and project a point onto a cylinder.
| JavaScript | C# | What it computes |
|---|---|---|
marchStep | MarchStep | EX1: one frame of marching from p toward the line from → to at speed units per second. |
lineFrame | LineFrame | EX1: the midpoint, unit direction and length of the segment p1 → p2. |
planeFromPoint | PlaneFromPoint | EX2: the plane with normal direction m (any length) through q, as a unit normal n and D. |
signedDistance | SignedDistance | EX3: n · p − D; positive on the normal's side. |
shadowOnPlane | ShadowOnPlane | EX4: p − (n · p − D) n. |
linePlaneHit | LinePlaneHit | EX5: the point where the line through p1 and p2 crosses the plane; null (C#: false) when parallel. |
reflect | Reflect | EX5: d − 2 (d · n) n. |
projectToCylinder | ProjectToCylinder | EX6: the foot on the axis, pushed out to the radius; and whether the foot is within halfHeight of the center. |
Each row is one check, run on your functions with the published inputs below. The same table appears under the scene in the runner and in the Unity Console.
| # | Check | Expected | Tolerance | Points |
|---|---|---|---|---|
| 1 | EX1 marchStep: one step toward (4, 0, 3) | (0.8, 0, 0.6) | 0.001 | 10 |
| 2 | EX1 lineFrame: midpoint, direction, length | ((2.5, 2, 0), (0.6, 0.8, 0), 5) | 0.001 | 10 |
| 3 | EX2 planeFromPoint: unit normal n and D | ((0.3333, 0.6667, 0.6667), 0.3333) | 0.001 | 10 |
| 4 | EX3 signedDistance for P = (4, 1, 0) and P2 = (-1, 0, 0) | (1.6667, -0.6667) | 0.001 | 10 |
| 5 | EX4 shadowOnPlane of P | (3.4444, -0.1111, -1.1111) | 0.001 | 13 |
| 6 | EX5 linePlaneHit for the segment P to P2 | (0.4286, 0.2857, 0) | 0.001 | 13 |
| 7 | EX5 reflect: the unit direction P to P2 reflected about n | (-0.6755, 0.414, 0.6101) | 0.001 | 13 |
| 8 | EX6 projectToCylinder: (1.2, 0.6, -0.9), point and inside | ((0.4, 0.6, -0.3), true) | 0.001 | 11 |
| 9 | EX6 projectToCylinder: (0.9, 1.4, 0.4), point and inside | ((0.4569, 1.4, 0.2031), false) | 0.001 | 10 |
{
"march": {
"p": [ 0, 0, 0 ],
"from": [ 0, 0, 0 ],
"to": [ 4, 0, 3 ],
"speed": 2,
"dt": 0.5
},
"line": {
"p1": [ 1, 0, 0 ],
"p2": [ 4, 4, 0 ]
},
"plane": {
"m": [ 1, 2, 2 ],
"q": [ 1, 0, 0 ]
},
"P": [ 4, 1, 0 ],
"P2": [ -1, 0, 0 ],
"cyl": {
"c": [ 0, 0, 0 ],
"axis": [ 0, 1, 0 ],
"radius": 0.5,
"halfHeight": 1,
"inside": [ 1.2, 0.6, -0.9 ],
"outside": [ 0.9, 1.4, 0.4 ]
}
}Build each function from primitives (dot, cross, normalize, length, component access, + − × ÷, sqrt.) and use the engine's own helper, where one exists, only to check your result. These are off limits in your submission:
| Track | Off limits |
|---|---|
| WebGL (JavaScript) | Vector3.projectOnVector, projectOnPlane, reflect, angleTo; THREE.Plane and THREE.Ray. |
| Unity (C#) | Vector3.Project, ProjectOnPlane, Reflect, Angle, MoveTowards, Lerp; the Plane struct. |
git clone https://github.com/mgav-uwb/UWB-CSS-551-AU26-homework.git, or Code, then Download ZIP. It gains each homework the day it goes out; git pull fetches it.python3 -m http.server 8000 and open http://localhost:8000/homework/run.html?hw=hw02.lib/skeletons/hw02.js, the only file you change, and reload: the Checks table under the scene compares your numbers with the ones below.The unfilled skeleton runs on this site too, so you can see the page before you start. The setup, the blank page a file opened from disk gives, and how to read the Checks table are in WebGL and three.js for This Course.
homework/hw02/unity/ into Assets/HW02/.Checks component (namespace CSS551.HW02), and press Play: the Console lists every check with your value and the expected one.HW02.cs; the other files are given.The Unity files compile against a stand-in for the UnityEngine API and pass their checks with the reference solution, but they are new this quarter and have not yet been opened in the Unity editor. If one does not compile in 6000.3.11f1, post the error on the Canvas board and use the WebGL track meanwhile.
hw02.js.Library/, Temp/, Logs/ and obj/.Grading runs your functions twice: on the published inputs above and on a second set of inputs that is not published. A check earns its points only when your value is within its tolerance on both, so the numbers have to come from the math. The rubric score is the sum of the points earned, out of 100; it counts as 25 course points (the rubric score divided by 4). A submission that does not load or compile earns no check points. Name any collaborators and tools in the submission comment.