UI: Updated drawing of algorithm info
This commit is contained in:
@@ -26,7 +26,7 @@ sourceSets {
|
|||||||
|
|
||||||
task copyKotlinLib(type: Copy) {
|
task copyKotlinLib(type: Copy) {
|
||||||
from "${projectDir}/kotlinJsRequiredFiles/kotlin.js"
|
from "${projectDir}/kotlinJsRequiredFiles/kotlin.js"
|
||||||
from "${projectDir}/kotlinJsRequiredFiles/package.json"
|
from "${projectDir}/package.json"
|
||||||
|
|
||||||
into "${projectDir}/build/js"
|
into "${projectDir}/build/js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class ControllerEmulator : Controller {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val currentDistance = Math.round(Math.sqrt(Math.pow(xIntersection - xSensor0, 2.0)
|
val currentDistance = Math.round(Math.sqrt(Math.pow(xIntersection - xSensor0, 2.0)
|
||||||
+ Math.pow(yIntersection - ySensor0, 2.0)))
|
+ Math.pow(yIntersection - ySensor0, 2.0)) * 1000000);
|
||||||
if (currentDistance < result) {
|
if (currentDistance < result) {
|
||||||
result = currentDistance
|
result = currentDistance
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ abstract class AbstractAlgorithm(val thisCar: Car, val exchanger: Exchanger<IntA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sum != 0) {
|
if (sum != 0) {
|
||||||
result[i] = (sum.toDouble()) / (copyElemCount)
|
result[i] = (sum.toDouble()) / (copyElemCount*1000000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
<div class="container" id="body-cont">
|
<div class="container" id="body-cont">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Canvas -->
|
<!-- Canvas -->
|
||||||
<div class="col-md-8"> <canvas id="pathCanvas" width="720" height="560"></canvas> </div>
|
<div class="col-md-8"> <canvas id="pathCanvas" width="1024" height="768"></canvas> </div>
|
||||||
|
|
||||||
<!-- Control Pnael -->
|
<!-- Control Pnael -->
|
||||||
<div class="col-md-1 center-block">
|
<div class="col-md-1 center-block">
|
||||||
|
|||||||
+23
-14
@@ -34,6 +34,21 @@ function drawCar(carPosition) {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawLine(line) {
|
||||||
|
var begin_x = 0;
|
||||||
|
var begin_y = (line.A * (0 - zero.x) + line.C) / line.B + zero.y;
|
||||||
|
|
||||||
|
var end_x = canvas.width;
|
||||||
|
var end_y = (line.A * (canvas.width - zero.x) + line.C) / line.B + zero.y;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(begin_x, begin_y);
|
||||||
|
ctx.lineTo(end_x, end_y);
|
||||||
|
ctx.strokeStyle = foundColour;
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
function drawSegment(segment, colour) {
|
function drawSegment(segment, colour) {
|
||||||
console.log("Drawing segment from (" + segment.begin.x + ", " + segment.begin.y + ") to (" + segment.end.x + ", " + segment.end.y + ")")
|
console.log("Drawing segment from (" + segment.begin.x + ", " + segment.begin.y + ") to (" + segment.end.x + ", " + segment.end.y + ")")
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
@@ -87,6 +102,8 @@ function createLine(A, B, C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drawDebug(data) {
|
function drawDebug(data) {
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
// Parse protobuf into geometry primitives
|
// Parse protobuf into geometry primitives
|
||||||
var foundLines = [];
|
var foundLines = [];
|
||||||
for (var i = 0; i < data.A.length; i++) {
|
for (var i = 0; i < data.A.length; i++) {
|
||||||
@@ -110,15 +127,7 @@ function drawDebug(data) {
|
|||||||
y: 0
|
y: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var foundSegments = [];
|
|
||||||
for (var i = 0; i < foundLines.length - 1; ++i) {
|
|
||||||
var curLine = foundLines[i];
|
|
||||||
var nextLine = foundLines[i + 1];
|
|
||||||
|
|
||||||
var intersectionPoint = intersectLines(curLine, nextLine);
|
|
||||||
foundSegments.push(createSegment(lastPoint, intersectionPoint));
|
|
||||||
lastPoint = intersectionPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
var referenceSegments = [];
|
var referenceSegments = [];
|
||||||
var corners = [];
|
var corners = [];
|
||||||
@@ -140,13 +149,13 @@ function drawDebug(data) {
|
|||||||
referenceSegments.push(createSegment(corners[corners.length - 1], corners[0]));
|
referenceSegments.push(createSegment(corners[corners.length - 1], corners[0]));
|
||||||
|
|
||||||
// draw everything
|
// draw everything
|
||||||
|
console.log("Drawing car position");
|
||||||
drawCar(carPosition);
|
drawCar(carPosition);
|
||||||
|
|
||||||
console.log("Drawing foundSegments")
|
|
||||||
for (var i = 0; i < foundSegments.length; ++i) {
|
|
||||||
drawSegment(foundSegments[i], foundColour);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
console.log("Drawing found Lines");
|
||||||
|
for (var i = 0; i < foundLines.length; ++i) {
|
||||||
|
drawLine(foundLines[i]);
|
||||||
|
}
|
||||||
console.log("Drawing referenceSegments")
|
console.log("Drawing referenceSegments")
|
||||||
for (var i = 0; i < referenceSegments.length; ++i) {
|
for (var i = 0; i < referenceSegments.length; ++i) {
|
||||||
drawSegment(referenceSegments[i], referenceColour);
|
drawSegment(referenceSegments[i], referenceColour);
|
||||||
|
|||||||
Reference in New Issue
Block a user