Common Configuration Issues and Solutions
When setting up a development environment for graphics programming on Windows 10, integrating libraries like Eigen and OpenCV can sometimes present challenges. This guide addresses typical problems encountered during the setup process for GAMES101 assignments.
1. OpenCV Installation Error
An error during the OpenCV build process, such as mingw32-make[1]: CMakeFiles\Makefile2: No such file or directory, may occur. A potential solution is to change the installation or build directory. This issue is often related to special characters in the path, such as parentheses, wich can cause problems with build scripts.
2. Eigen Header Not Found
If the compiler reports a fatal error like fatal error: Eigen3/Core: No such file or directory, it indicates that the build system cannot locate the Eigen headers. This is resolved by explicitly adding the path to the Eigen include directory in your CMakeLists.txt file using the include_directories command.
# In your CMakeLists.txt
include_directories("C:/path/to/your/eigen3/include/eigen3")
3. OpenCV Linking Errors
Linker errors, such as LNK2019: unresolved external symbol, typically mean that the linker cannot find the required OpenCV libraries. For CMake projects, the correct approach is to use find_package and target_link_libraries to ensure all necessary libraries are linked correctly.
The following CMakeLists.txt example demonstrates a robust way to configure the project, ensuring both Eigen and OpenCV are properly included and linked.
cmake_minimum_required(VERSION 3.10)
project(Assignment1)
# Find the OpenCV package
find_package(OpenCV REQUIRED)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
# Include directories for Eigen and OpenCV
include_directories("C:/path/to/eigen3/include/eigen3")
include_directories(${OpenCV_INCLUDE_DIRS})
# Create the executable
add_executable(Assignment1 main.cpp)
# Link the OpenCV libraries
target_link_libraries(Assignment1 ${OpenCV_LIBRARIES})
GAMES101 Assignment 0: Homogeneous Coordinates
For the first assignment, you are asked to transform a point P=(2,1) by first rotating it 45 degrees counter-clockwise around the origin, and then translating it by (1,2). Using homogeneous coordinates simplifies this by representing 2D transformations as matrix multiplications.
The following C++ code uses the Eigen library to perform these calculations.
#include <iostream>
#include <cmath>
#include <Eigen/Dense>
int main() {
// Define the point P in homogeneous coordinates
Eigen::Vector3d point(2.0, 1.0, 1.0);
// Define the rotation angle in radians
const double angle_degrees = 45.0;
const double angle_radians = angle_degrees * M_PI / 180.0;
// Create the rotation matrix for a 45-degree counter-clockwise rotation
Eigen::Matrix3d rotation_matrix;
rotation_matrix <<
std::cos(angle_radians), -std::sin(angle_radians), 0.0,
std::sin(angle_radians), std::cos(angle_radians), 0.0,
0.0, 0.0, 1.0;
// Create the translation matrix for a translation of (1, 2)
Eigen::Matrix3d translation_matrix;
translation_matrix <<
1.0, 0.0, 1.0,
0.0, 1.0, 2.0,
0.0, 0.0, 1.0;
// Apply the transformations: translate then rotate
Eigen::Vector3d transformed_point = translation_matrix * rotation_matrix * point;
// Output the result
std::cout << "Transformed point coordinates: " << transformed_point.transpose() << std::endl;
return 0;
}