1#include "math/Vector3.hpp"
17std::vector<std::pair<int, int>>
bresenhamLow(
int x0,
int y0,
int x1,
int y1) {
25 int difference = 2 * dy - dx;
28 std::vector<std::pair<int, int>> points;
30 for (
int x = x0; x <= x1; ++x) {
31 points.push_back(std::make_pair(x, y));
35 difference += 2 * (dy - dx);
47std::vector<std::pair<int, int>>
bresenhamHigh(
int x0,
int y0,
int x1,
int y1) {
55 int difference = 2 * dx - dy;
58 std::vector<std::pair<int, int>> points;
60 for (
int y = y0; y <= y1; ++y) {
61 points.push_back(std::make_pair(x, y));
65 difference += 2 * (dx - dy);
87std::vector<std::pair<int, int>>
bresenham(
int x0,
int y0,
int x1,
int y1) {
88 if (std::abs(y1 - y0) < std::abs(x1 - x0)) {
114 Vector3 edgeAB = vertexB - vertexA;
115 Vector3 edgeAC = vertexC - vertexA;
123 double denominator = dotABAB * dotACAC - dotABAC * dotABAC;
125 double v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denominator;
126 double w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denominator;
127 double u = 1.0 - v - w;
The 3D vector class.
Definition Vector3.hpp:20
static double dot(const Vector3 &a, const Vector3 &b)
Returns the dot product of two vectors.
Definition Vector3.hpp:67
The t software 3D graphics library namespace.
Definition algorithms.hpp:12
std::vector< std::pair< int, int > > bresenhamHigh(int x0, int y0, int x1, int y1)
Used internally by bresenham.
Definition algorithms.hpp:47
std::vector< std::pair< int, int > > bresenhamLow(int x0, int y0, int x1, int y1)
Used internally by bresenham.
Definition algorithms.hpp:17
std::vector< std::pair< int, int > > bresenham(int x0, int y0, int x1, int y1)
Computes and returns the points of a line using the Bresenham's line algorithm.
Definition algorithms.hpp:87
Vector3 barycentric(Vector3 point, Vector3 vertexA, Vector3 vertexB, Vector3 vertexC)
Computes and returns the barycentric coordinates of a point in a triangle.
Definition algorithms.hpp:112