Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions SourceCode/GPS/Classes/CFenceLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,34 @@ public void CalculateFenceLineHeadings()
{
//to calc heading based on next and previous points to give an average heading.
int cnt = fenceLine.Count;
vec3[] arr = new vec3[cnt];
cnt--;
fenceLine.CopyTo(arr);
fenceLine.Clear();
if (cnt > 1)
{
vec3[] arr = new vec3[cnt];
cnt--;
fenceLine.CopyTo(arr);
fenceLine.Clear();

//first point needs last, first, second points
vec3 pt3 = arr[0];
pt3.heading = Math.Atan2(arr[1].easting - arr[cnt].easting, arr[1].northing - arr[cnt].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
fenceLine.Add(pt3);
//first point needs last, first, second points
vec3 pt3 = arr[0];
pt3.heading = Math.Atan2(arr[1].easting - arr[cnt].easting, arr[1].northing - arr[cnt].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
fenceLine.Add(pt3);

//middle points
for (int i = 1; i < cnt; i++)
{
pt3 = arr[i];
pt3.heading = Math.Atan2(arr[i + 1].easting - arr[i - 1].easting, arr[i + 1].northing - arr[i - 1].northing);
//middle points
for (int i = 1; i < cnt; i++)
{
pt3 = arr[i];
pt3.heading = Math.Atan2(arr[i + 1].easting - arr[i - 1].easting, arr[i + 1].northing - arr[i - 1].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
fenceLine.Add(pt3);
}

//last and first point
pt3 = arr[cnt];
pt3.heading = Math.Atan2(arr[0].easting - arr[cnt - 1].easting, arr[0].northing - arr[cnt - 1].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
fenceLine.Add(pt3);
}

//last and first point
pt3 = arr[cnt];
pt3.heading = Math.Atan2(arr[0].easting - arr[cnt - 1].easting, arr[0].northing - arr[cnt - 1].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
fenceLine.Add(pt3);
}

public void FixFenceLine(int bndNum)
Expand Down
57 changes: 30 additions & 27 deletions SourceCode/GPS/Classes/CTurnLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,41 @@ public void CalculateTurnHeadings()
{
//to calc heading based on next and previous points to give an average heading.
int cnt = turnLine.Count;
vec3[] arr = new vec3[cnt];
cnt--;
turnLine.CopyTo(arr);
turnLine.Clear();

//first point needs last, first, second points
vec3 pt3 = arr[0];
pt3.heading = Math.Atan2(arr[1].easting - arr[cnt].easting, arr[1].northing - arr[cnt].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
turnLine.Add(pt3);

//middle points
for (int i = 1; i < cnt; i++)
if (cnt > 1)
{
pt3 = arr[i];
pt3.heading = Math.Atan2(arr[i + 1].easting - arr[i - 1].easting, arr[i + 1].northing - arr[i - 1].northing);
vec3[] arr = new vec3[cnt];
cnt--;
turnLine.CopyTo(arr);
turnLine.Clear();

//first point needs last, first, second points
vec3 pt3 = arr[0];
pt3.heading = Math.Atan2(arr[1].easting - arr[cnt].easting, arr[1].northing - arr[cnt].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
turnLine.Add(pt3);
}

//first point
vec3 pt2 = arr[0];
pt2.heading = Math.Atan2(arr[1].easting - arr[0].easting, arr[1].northing - arr[0].northing);
if (pt2.heading < 0) pt2.heading += glm.twoPI;
turnLine.Insert(0, new vec3(pt2));
//middle points
for (int i = 1; i < cnt; i++)
{
pt3 = arr[i];
pt3.heading = Math.Atan2(arr[i + 1].easting - arr[i - 1].easting, arr[i + 1].northing - arr[i - 1].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
turnLine.Add(pt3);
}

//last point
pt2 = arr[arr.Length - 1];
pt2.heading = Math.Atan2(arr[arr.Length - 1].easting - arr[arr.Length - 2].easting,
arr[arr.Length - 1].northing - arr[arr.Length - 2].northing);
if (pt2.heading < 0) pt2.heading += glm.twoPI;
turnLine.Add(new vec3(pt2));
//first point
vec3 pt2 = arr[0];
pt2.heading = Math.Atan2(arr[1].easting - arr[0].easting, arr[1].northing - arr[0].northing);
if (pt2.heading < 0) pt2.heading += glm.twoPI;
turnLine.Insert(0, new vec3(pt2));

//last point
pt2 = arr[arr.Length - 1];
pt2.heading = Math.Atan2(arr[arr.Length - 1].easting - arr[arr.Length - 2].easting,
arr[arr.Length - 1].northing - arr[arr.Length - 2].northing);
if (pt2.heading < 0) pt2.heading += glm.twoPI;
turnLine.Add(new vec3(pt2));
}
}

public void FixTurnLine(double totalHeadWidth, double spacing)
Expand Down
Loading