summaryrefslogtreecommitdiffstats
path: root/Project/Line.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-04-24 17:39:03 -0300
committerGitHub <noreply@github.com>2017-04-24 17:39:03 -0300
commit7804c1bd2c0bd2a5f135c30b20991e8187581cc6 (patch)
tree725e524253d6fd714460402194b408cb33b80b3f /Project/Line.cpp
parent69131a727782090ffd7cb467f449e8f26d3d2949 (diff)
parent9529a6ed44645842adc6f938478acc1dfa17a284 (diff)
downloadPSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.tar.gz
PSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.tar.xz
PSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.zip
Merge pull request #28 from Thales1330/wip/generic-controllers
Wip generic controllers. Chart view implementation required, creating new branch....
Diffstat (limited to 'Project/Line.cpp')
-rw-r--r--Project/Line.cpp35
1 files changed, 0 insertions, 35 deletions
diff --git a/Project/Line.cpp b/Project/Line.cpp
index 66a43c5..86d947c 100644
--- a/Project/Line.cpp
+++ b/Project/Line.cpp
@@ -267,41 +267,6 @@ void Line::MoveNode(Element* parent, wxPoint2DDouble position)
UpdatePowerFlowArrowsPosition();
}
-double Line::PointToLineDistance(wxPoint2DDouble point, int* segmentNumber) const
-{
- //[Ref] http://geomalgorithms.com/a02-_lines.html
- double distance = 100.0; // Big initial distance.
- wxPoint2DDouble p0 = point;
-
- for(int i = 1; i < (int)m_pointList.size() - 2; i++) {
- double d = 0.0;
-
- wxPoint2DDouble p1 = m_pointList[i];
- wxPoint2DDouble p2 = m_pointList[i + 1];
-
- wxPoint2DDouble v = p2 - p1;
- wxPoint2DDouble w = p0 - p1;
-
- double c1 = w.m_x * v.m_x + w.m_y * v.m_y;
- double c2 = v.m_x * v.m_x + v.m_y * v.m_y;
-
- if(c1 <= 0.0) {
- d = std::sqrt(std::pow(p0.m_y - p1.m_y, 2) + std::pow(p0.m_x - p1.m_x, 2));
- } else if(c2 <= c1) {
- d = std::sqrt(std::pow(p0.m_y - p2.m_y, 2) + std::pow(p0.m_x - p2.m_x, 2));
- } else {
- d = std::abs((p2.m_y - p1.m_y) * p0.m_x - (p2.m_x - p1.m_x) * p0.m_y + p2.m_x * p1.m_y - p2.m_y * p1.m_x) /
- std::sqrt(std::pow(p2.m_y - p1.m_y, 2) + std::pow(p2.m_x - p1.m_x, 2));
- }
- if(d < distance) {
- distance = d;
- if(segmentNumber) *segmentNumber = i;
- }
- }
-
- return distance;
-}
-
bool Line::GetContextMenu(wxMenu& menu)
{
menu.Append(ID_EDIT_ELEMENT, _("Edit line"));