Computer Graphics and NumPy Essentials
Course context and resources
The class is a combined undergraduate and graduate computer graphics course. Instructor orientation and navigation to resources are given on the course web page.
Access the course page via the university site: go to ranger.uta.edu, search the instructor’s name or the course, and you’ll reach the course page.
Key page sections (on the first link):
Syllabus: overview and fast scan of requirements.
Teaching assistant page: TA name, office hours, email.
Assignments: announcements and links; Canvas is used to submit notifications when assignments are ready.
Handouts and supplementary material: guidelines, tutorials, Q&As.
Useful links: related graphic sites (outside resources).
Old tests: all past tests are posted here for access to everyone (no selective access).
Syllabus and course logistics (via the university catalog and Canvas):
Course delivery: on-campus, not online; you must be present.
Echo 360: class recording is available; you may record for personal use, but the session is already recorded.
Study load: guidance on outside-study time; learning outcomes are listed.
Required texts: efforts to minimize costs; online materials preferred; some recommended/optional books may be helpful.
Important note on accessibility and equity: the instructor provides all materials online so all students have access to resources.
Overview of grading and course structure (to be read in full on your own):
Assignments and quizzes, two major exams, and grading thresholds.
Absolute (fixed) grade thresholds to reduce uncertainty; no curving.
Quizzes are unannounced, frequent, and designed to ensure consistent study habits; they are numerical/programming-focused (no essay questions).
Two-exam policy; no makeup unless medical with written excuse; missed exam may be substituted by the average of others.
Quizzes/exams are designed to promote step-by-step learning; 24-hour grace period for assignments with no penalty beyond that grace window.
General policy emphasis from the instructor:
Respect for all students; no preferential treatment in grading or opportunities.
Email etiquette: use university email; in the subject line specify the class; in the first line of the email state the purpose (e.g., “I want you to regrade my quiz Q staff and here is why”).
Attendance is not formally taken, but you are responsible for any quizzes; being present helps avoid missing work.
Generative AI policy and academic integrity:
AI tools may be used as a help, but you must understand and be able to explain the output; do not present AI-generated work as your own without understanding.
Work may be checked with MOSS (a plagiarism-detection system) to assess similarity; if two programs look too similar, it may be flagged as collaboration.
Do not share your code with others; rewrite and personalize AI-generated outcomes; ensure you can justify every line of code you submit.
If you use AI, you must demonstrate understanding by adapting the output to your own thinking and approach.
Industry practice and expectations:
In graphics, there’s a balance between using AI/tools and doing the computation yourself; know when to rely on prebuilt routines and when to implement underlying concepts manually for understanding.
Software and environment notes:
Primary language in class: Python; other languages (C, C++, JavaScript, etc.) are allowed if you can get help from the GA; most examples use Python.
Tools: Visual Studio Code, PyCharm; issues may arise on Mac vs Windows (especially with Mac M1/M2 differences); inform the instructor if conflicts arise.
Summary takeaways:
The course covers math foundations (vectors, matrices, planes, parametric equations, coordinate systems) and practical graphics transforms (translate, rotate, scale) in 3D.
NumPy is a central tool for handling arrays, broadcasting, and vectorized operations; you’ll work with 1D/2D/3D arrays, shapes, sizes, and dtypes, and you’ll learn to manipulate them efficiently.
NumPy fundamentals
NumPy purpose and data model
NumPy provides arrays (ndarray) that are homogeneous collections of elements; each element has the same data type (dtype).
Contrast with Python lists: a list can hold mixed types, but NumPy arrays must have a single dtype (e.g., int, float, string).
Lists vs arrays example behavior
A Python list can contain integers and a string, e.g., [1, 2, 3, 'a']; converting to a NumPy array causes all elements to be cast to a common dtype (often string if mixed types).
In NumPy, a numeric array cannot contain both numbers and strings; if mixed, elements are coerced to a string dtype.
Basic array properties
Shape: the dimensionality and size in each dimension, denoted as a tuple, e.g., for a 2D array shape is (rows, cols).
Size: total number of elements in the array, e.g., size = product(shape).
Number of dimensions: ndim, e.g., a 2D array has ndim = 2.
Data type: dtype, e.g., int64, float64, object, etc.
Creating basic arrays
Zeros and ones: ,
Numerical ranges: in Python you have range(), but in NumPy you typically use to generate evenly spaced values.
More controlled sampling: to create a fixed number of samples between start and stop.
Reshaping, flattening, and transposing are common: (transpose).
Array vs list printing and representation
Printing a NumPy array shows elements with brackets and commas; Python lists print similarly; difference is that arrays carry shape and dtype metadata.
Basic operations and broadcasting
Scalar broadcasting: a NumPy array multiplied by a scalar applies the operation elementwise to all entries.
Broadcasting rules (high level): when performing operations on arrays of different shapes, NumPy automatically broadcasts smaller arrays across the larger array if certain dimensionality constraints are met (trailing dimensions align, and dimensions of size 1 can be stretched to match).
Example intuition: a 2D array (m x n) can be added to a 1D array (n,), by broadcasting the 1D array across the m rows.
Dot product and elementwise operations
np.dot or the @ operator performs matrix multiplication (dot product) between compatible shapes.
Elementwise operations use standard arithmetic with broadcasting; be careful when the intent is matrix multiplication vs elementwise product.
Common NumPy operations you’ll use
Sine and cosine: (universal functions).
Shape manipulations: .
Sizing functions: to inspect arrays.
Practical tips
Know the difference between a list and an ndarray visually by examining printed output; lists show Python objects separated by comma and spaces; NumPy arrays show elements with uniform dtype and a bracketed format with commas.
When you need a large array (e.g., an image 100x100 or 1000x1000) filled with zeros or ones, use or .
Examples touched in lecture
Creating a small 2x3 array and inspecting its properties: shape, size, dtype, and the resulting printout.
Demonstration of type promotion when mixing int/float types and the effect on the resulting dtype.
NumPy shapes, dimensions, and broadcasting in depth
Shape, size, and ndim
Shape: tuple of dimension lengths, e.g., a 2x3 array has shape .
Size: total number of elements, .
ndim (number of dimensions): for a 2x3 array, .
Shape versus size examples
A 2D array of shape (2,3) has size 6, and its elements can be indexed as with i∈{0,1}, j∈{0,1,2}.
Understanding dimension tagging and indexing
A 1D array has shape (n,); a 2D array has shape (m, n); a 3D array has shape (d, m, n). The meaning of shape depends on the axis ordering.
Broadcasting rules in practice
If shapes are not identical, NumPy attempts to align trailing dimensions and broadcast if possible: a dimension with size 1 can be stretched to match the other array's size along that axis.
Example scenarios:
Shape (m, n) and (n,) can broadcast to (m, n).
Shape (m, n) and (m, 1) broadcast to (m, n).
It’s important to understand broadcasting to avoid subtle bugs when performing numeric operations in graphics pipelines.
Practical pitfalls
Mixing shapes that are not broadcast-compatible raises a ValueError.
When in doubt, inspect the shapes of your operands with .shape before performing operations.
Basic transforms for computer graphics
Transformations overview
Core operations: translation, rotation, scaling; those are the building blocks for moving, rotating, and resizing 2D/3D objects.
In 3D graphics, transforms are usually represented as matrices and applied to points or to homogeneous coordinates; translation is often represented as an addition to coordinates or as a matrix operation in homogeneous coordinates.
Translation
Concept: move every point of an object by a fixed offset (Δx, Δy, Δz).
In pure math (without homogeneous coordinates): v' = v + t where v is a point, t is the translation vector, e.g., t = (Δx, Δy, Δz).
Scaling
Concept: scale coordinates along axes by factors (Sx, Sy, Sz).
Matrix form (3D): S = diag(Sx, Sy, Sz); v' = S v (for column vectors).
If Sx=Sy=Sz=2, the object doubles in size around the origin.
Nonuniform scaling (Sx ≠ Sy or Sz) stretches differently along axes; beware of distortion.
Rotation (3D)
Rotation is performed around an axis (X, Y, or Z) or around an arbitrary axis.
Rotation around X-axis (Rx):
Correct form:
Rotation around Y-axis (Ry):
Rotation around Z-axis (Rz):
Direction convention: clockwise vs counterclockwise depends on viewpoint; instructor uses a convention where clockwise is positive by default unless specified, and the sign of off-diagonal terms changes with the chosen axis and viewpoint.
2D rotation quick reference
2D rotation matrix:
Vectors vs points for transforms
Points represent locations in space; translation moves points by offset.
Vectors represent directions from origin; translation does not move a vector in space (vectors are not anchored to a location in space).
In graphics, a common pitfall is applying translations to vectors; vectors are invariant under translation.
Practical notes about orientation and handedness
Right-handed vs left-handed coordinate systems: orientation depends on axis order and the direction of positive axes.
Consistency is crucial across the pipeline; switching handiness mid-project causes incorrect transforms.
Planes, normals, and distances in 3D
Plane equation and normal vector
A plane in 3D can be written as: where the normal vector is .
The plane is perpendicular to the normal vector
Distance from origin to a plane
The distance from the origin to the plane Ax+By+Cz+D=0 is:
Example: For the plane , the distance is
Unit normal and normalized plane form
Normalize the normal vector:
Normalize the plane constants with the same factor: if we divide the whole equation by (\sqrt{A^2 + B^2 + C^2}), we obtain a unit normal form with a corresponding D' = D / \sqrt{A^2 + B^2 + C^2}.
The distance from the origin to the plane is then
Plane through the origin vs offset planes
If D=0, the plane passes through the origin; distance d=0.
Scaling the entire plane equation by a nonzero scalar yields the same geometric plane.
Converting plane to slope-intercept form in 3D
When C ≠ 0, you can solve for z:
Practical GeoGebra visualization
A simple tool (GeoGebra) can animate the plane by treating A,B,C,D as sliders to visualize how the plane moves with the normal and offset.
Relationship with graphics pipelines
In 3D graphics pipelines, planes and normals help with culling, lighting, shading, and clipping decisions.
Parametric representations and handedness
Parametric equations for lines in 3D
A line in 3D can be written parametrically as:
This form extends naturally to higher dimensions; it is particularly powerful for curves and surfaces.
Example intuition: pick a parameter t, compute a point on the line for each t, and plot points as t varies.
Parametric lines in 2D and 3D
In 2D, you can still use parametric form with x(t) and y(t) (z is not present).
In 3D, you have x(t), y(t), z(t) as above; different t values trace the line in 3D space.
Vector and point distinctions in graphics
Vectors represent directions and magnitudes; coordinates can serve as vectors but should be treated as direction only unless anchored at a point.
The origin is a reference; translating a point changes its coordinates, whereas translating a vector would shift its location if treated as a point, but vectors themselves do not have a fixed location.
Industry perspective on coordinate systems
3D graphics often rely on right-handed coordinate systems for consistency; some books use left-handed systems. The key is to be explicit and consistent throughout the pipeline.
Graphics workflow and practical considerations
From numbers to images to visuals
Computer graphics takes coordinates of 3D points (vertices) and applies a sequence of transformations (translate, rotate, scale) to produce a new set of coordinates.
The final 2D screen rendering is a projection step, converting 3D coordinates into 2D screen coordinates for display.
Parametric techniques for graphics generation
Many curves and surfaces (e.g., cubic curves, Bezier, etc.) are naturally defined parametrically.
Parametric representations enable straightforward scaling to higher dimensions without rewriting the equations.
Industry practice around numerical computations
In graphics, many operations are performed using matrices (and sometimes broadcasting) for efficiency.
When performance matters (e.g., millions of polygons), using vectorized or GPU-accelerated approaches is essential; explicit per-element loops are slow.
Quick recap of key mathematical concepts used in graphics
Planes and distances
Plane equation: with normal vector .
Distance from origin to plane:
Unit normal:
Transformations as matrices (and a translation vector)
Translation: add offset to coordinates:
Scaling: multiply by a scale matrix:
Rotation about axes (3D) with rotation matrices given above.
Parametric lines and curves
Line in 3D:
Parametric curves enable easy extension to higher dimensions and facilitate plotting and testing.
Notes on using AI and academic integrity (practice reminders)
AI usage can assist with code generation and problem solving, but you must understand and be able to explain every line and the rationale behind it.
If you rely on AI outputs, adapt and rewrite in your own words and structure; do not submit copied AI outputs as your own work.
Tools like MOSS can detect similarities; avoid sharing code verbatim; we expect individual understanding and unique implementations.
Always document and justify your changes when using AI assistance in your work; demonstrate learning and mastery, not just correct results.
Quick glossary (for exam-readiness)
Shape: the tuple describing the size of each dimension of an array, e.g., $(2,3)$ for a 2 by 3 matrix.
Size: the total number of elements in an array; for a $(2,3)$ array, size = $6$.
ndim: number of dimensions of an array.
dtype: the data type of elements in an array (e.g., int64, float64).
Broadcasting: NumPy mechanism to apply operations to arrays of different shapes by automatically expanding to a common shape when possible.
Homogeneous coordinates: a way to represent translation as matrix multiplication by using a fourth coordinate (1) to enable translation via a single matrix multiply (not discussed in depth here, but common in graphics pipelines).
End of notes
Based on the provided notes for the computer graphics course, there are no specific important dates like historical events or fixed deadlines mentioned. The notes primarily cover course logistics, content, policies, and technical information about NumPy and graphics transformations. However, it does mention a "24-hour grace period for assignments with no penalty beyond that grace window" which is a policy related to deadlines.