Skip to content

Commit

Permalink
fixed for Line of Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Spinelli committed Mar 26, 2024
1 parent a8e34c7 commit ee2f1e4
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.1.58
version=0.1.59
android.enableBuildCache=true
org.gradle.jvmargs=-Xmx1536M

2 changes: 1 addition & 1 deletion renderer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ afterEvaluate{

ext {
PUBLISH_GROUP_ID = 'io.github.missioncommand'
PUBLISH_VERSION = '0.1.58'
PUBLISH_VERSION = '0.1.59'
PUBLISH_ARTIFACT_ID = 'mil-sym-android-renderer'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ private static void DrawChannel2(double[] pixels,

// Line of contact looks bad with small channel corners extending out
if (linetype == TacticalLines.LC || linetype == TacticalLines.LC_HOSTILE)
factor = 1;
{
clsUtility.GetLCSegments(pixels2, segments);
}
else
clsUtility.GetSegments(pixels2, segments, factor);

clsUtility.GetSegments(pixels2, segments, factor);
partitions = new ArrayList();
GetPartitions(segments, partitions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,77 @@ protected static void GetSegments(double[] pixels,
}
}

/**
* Called by clsChannelUtility. The segments are used for managing double-backed segments
* for channel types. If the new point is double-backed then the segment at that index will be false.
*
* @param pixels the client points as 2-tuples x,y in pixels
* @param segments OUT - the segments
*/
protected static void GetLCSegments(double[] pixels,
boolean[] segments) {
try
{
int j = 0;
ref<double[]> m1 = new ref();
ref<double[]> m2 = new ref();
long numPoints = 0;
boolean bolVertical1 = false;
boolean bolVertical2 = false;

POINT2 pt0F = new POINT2(0, 0);
POINT2 pt1F = new POINT2(0, 0);
POINT2 pt2F = new POINT2(0, 0);

segments[0] = true;
double[] angles = new double[segments.length];
angles[0] = 0f;
numPoints = pixels.length / 2;
for (j = 0; j < numPoints - 2; j++)
{
pt0F.x = (double) pixels[2 * j];
pt0F.y = (double) pixels[2 * j + 1];

pt1F.x = (double) pixels[2 * j + 2];
pt1F.y = (double) pixels[2 * j + 3];

pt2F.x = (double) pixels[2 * j + 4];
pt2F.y = (double) pixels[2 * j + 5];

double angle1 = Math.atan2(pt1F.y - pt0F.y,
pt1F.x - pt0F.x);
double angle2 = Math.atan2(pt1F.y - pt2F.y,
pt1F.x - pt2F.x);
double angle = angle1-angle2;// * 180/Math.PI;
double degrees = angle * 180/Math.PI;
//segments[j + 1] = false;
//segments[j + 1] = true;
if(angle < 0)
{
degrees = 360 + degrees;
}

if(degrees < 90)
{
segments[j + 1] = false;
}
else
segments[j + 1] = true;

angles[j+1] = degrees;

} //end for
//System.out.println(angles);
}
catch (Exception exc)
{
//System.out.println(e.getMessage());
//clsUtility.WriteFile("Error in clsUtility.GetSegments");
ErrorLogger.LogException(_className, "GetLCSegments",
new RendererException("Failed inside GetSegments", exc));
}
}

/**
* Sets the color for the current shape depending on the affiliation
* @param tg
Expand Down

0 comments on commit ee2f1e4

Please sign in to comment.