12 std::size_t point_count = std::ceil((this->domain_.y - this->domain_.x) / this->precision_);
14 std::vector<glm::vec2> points;
15 points.reserve(point_count);
16 for (std::size_t i = 0; i < point_count; i++)
18 double x = this->domain_.x + ((double)i * this->precision_);
19 double y = this->fn_(x);
21 points.emplace_back(x, y);
25 this->
vertices.reserve(points.size() * 2);
28 for (std::size_t i = 0; i < points.size(); i++)
30 if (i < points.size() - 1)
32 dx = points[i + 1].x - points[i].x;
33 dy = points[i + 1].y - points[i].y;
36 double theta1 = std::atan2(dy, dx);
37 double theta2 = ((std::numbers::pi / 2) - theta1);
39 double tx = (this->line_thickness_ / 2) * std::cos(theta2);
40 double ty = (this->line_thickness_ / 2) * std::sin(theta2);
42 auto const &point = points[i];
44 this->
vertices.push_back({glm::vec2(point.x + tx, point.y - ty), this->color_});
45 this->
vertices.push_back({glm::vec2(point.x - tx, point.y + ty), this->color_});