HighMap library (C++)
Loading...
Searching...
No Matches
edge.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
24#pragma once
25#include <cmath>
26
28
29namespace hmap
30{
31
40class Edge
41{
42public:
45 float w;
46
55 Edge(Point p1, Point p2, float w) : p1(p1), p2(p2), w(w)
56 {
57 }
58
66 Edge(Point p1, Point p2) : p1(p1), p2(p2), w(0)
67 {
68 }
69
78 float length()
79 {
80 return distance(p1, p2);
81 }
82};
83
84} // namespace hmap
Represents a line segment in 2D space.
Definition edge.hpp:41
Edge(Point p1, Point p2, float w)
Constructs an Edge object with specified start and end points and a weight.
Definition edge.hpp:55
float length()
Computes the length of the edge.
Definition edge.hpp:78
Point p2
The end point of the edge.
Definition edge.hpp:44
Edge(Point p1, Point p2)
Constructs an Edge object with specified start and end points and a default weight of 0.
Definition edge.hpp:66
Point p1
The start point of the edge.
Definition edge.hpp:43
float w
A weight associated with the edge.
Definition edge.hpp:45
A class to represent and manipulate 2D points that can carry a value.
Definition point.hpp:38
Definition algebra.hpp:28
float distance(const Point &p1, const Point &p2)
Calculates the distance between two points.
Definition points.cpp:93
Defines a class for representing and manipulating 3D points.