Browse Source

Inverse Zom Logic implemented.

refactor/sync-centralize
RUSHIL AMBARISH KADU 3 months ago
parent
commit
6a02df2e48
  1. 26
      steps/src/drawUtils.js
  2. 16
      steps/src/p5/zoomSketch.js

26
steps/src/drawUtils.js

@ -231,10 +231,10 @@ export function drawAxes(p, plotScales) {
} }
export function drawPointCloud(p, points, plotScales) {
export function drawPointCloud(p, points, plotScales, pointSize = 4) {
try { try {
// Set stroke weight for points. // Set stroke weight for points.
p.strokeWeight(4);
p.strokeWeight(pointSize);
// Get state of various toggles from the DOM. // Get state of various toggles from the DOM.
const useSnr = toggleSnrColor.checked; const useSnr = toggleSnrColor.checked;
const useCluster = toggleClusterColor.checked; const useCluster = toggleClusterColor.checked;
@ -325,7 +325,7 @@ export function drawPointCloud(p, points, plotScales) {
} }
} }
export function drawTrajectories(p, plotScales) {
export function drawTrajectories(p, plotScales, scaleFactor = 1) {
try { try {
const localTtcColors = ttcColors(p); const localTtcColors = ttcColors(p);
@ -372,7 +372,7 @@ export function drawTrajectories(p, plotScales) {
if (isCurrentlyStationary) { if (isCurrentlyStationary) {
// Stationary tracks are always green and dashed // Stationary tracks are always green and dashed
p.stroke(34, 139, 34, 220); p.stroke(34, 139, 34, 220);
p.strokeWeight(1);
p.strokeWeight(1 * scaleFactor);
p.drawingContext.setLineDash([3, 3]); p.drawingContext.setLineDash([3, 3]);
for (let i = 1; i < trajPts.length; i++) { for (let i = 1; i < trajPts.length; i++) {
// ... (draw fading stationary trajectory logic) // ... (draw fading stationary trajectory logic)
@ -448,7 +448,7 @@ export function drawTrajectories(p, plotScales) {
} }
} }
p.strokeWeight(1.5);
p.strokeWeight(1.5 * scaleFactor);
p.drawingContext.setLineDash([]); p.drawingContext.setLineDash([]);
// Fading trajectory logic (works for both modes) // Fading trajectory logic (works for both modes)
@ -476,7 +476,7 @@ export function drawTrajectories(p, plotScales) {
} }
} }
export function drawTrackMarkers(p, plotScales) {
export function drawTrackMarkers(p, plotScales, scaleFactor = 1) {
try { try {
const showDetails = toggleVelocity.checked; const showDetails = toggleVelocity.checked;
const useStationary = toggleStationaryColor.checked; const useStationary = toggleStationaryColor.checked;
@ -492,7 +492,7 @@ export function drawTrackMarkers(p, plotScales) {
const textLabels = []; const textLabels = [];
p.push(); p.push();
p.strokeWeight(2);
p.strokeWeight(2 * scaleFactor);
for (const track of appState.vizData.tracks) { for (const track of appState.vizData.tracks) {
if (toggleConfirmedOnly.checked && track.isConfirmed === false) continue; if (toggleConfirmedOnly.checked && track.isConfirmed === false) continue;
@ -506,7 +506,7 @@ export function drawTrackMarkers(p, plotScales) {
if (log) { if (log) {
const pos = log.correctedPosition; const pos = log.correctedPosition;
if (pos && pos.length === 2 && pos[0] !== null && pos[1] !== null) { if (pos && pos.length === 2 && pos[0] !== null && pos[1] !== null) {
const size = 5;
const size = 5 * scaleFactor;
const x = pos[0] * plotScales.plotScaleX; const x = pos[0] * plotScales.plotScaleX;
const y = pos[1] * plotScales.plotScaleY; const y = pos[1] * plotScales.plotScaleY;
@ -582,13 +582,13 @@ export function drawTrackMarkers(p, plotScales) {
p.push(); p.push();
p.fill(textColor); p.fill(textColor);
p.noStroke(); p.noStroke();
p.textSize(12);
p.textSize(12 * scaleFactor);
// Set alignment once // Set alignment once
// Note: we handle the flip manually // Note: we handle the flip manually
for (const label of textLabels) { for (const label of textLabels) {
p.push(); p.push();
p.translate(label.x + 10, label.y);
p.translate(label.x + 10 * scaleFactor, label.y);
p.scale(1, -1); // Flip text back up p.scale(1, -1); // Flip text back up
p.text(label.text, 0, 0); p.text(label.text, 0, 0);
p.pop(); p.pop();
@ -1040,7 +1040,7 @@ export function drawRegionsOfInterest(p, frameData, plotScales) {
} }
} }
export function drawClusterCentroids(p, clustersInput, plotScales) {
export function drawClusterCentroids(p, clustersInput, plotScales, scaleFactor = 1) {
try { try {
if (!clustersInput) { if (!clustersInput) {
return; // Do nothing if there's no cluster data return; // Do nothing if there's no cluster data
@ -1076,9 +1076,9 @@ export function drawClusterCentroids(p, clustersInput, plotScales) {
p.push(); p.push();
p.stroke(color); p.stroke(color);
p.strokeWeight(1.5);
p.strokeWeight(1.5 * scaleFactor);
const armLength = 5;
const armLength = 5 * scaleFactor;
p.line(x, y - armLength, x, y + armLength); p.line(x, y - armLength, x, y + armLength);
p.line(x - armLength, y, x + armLength, y); p.line(x - armLength, y, x + armLength, y);

16
steps/src/p5/zoomSketch.js

@ -263,20 +263,21 @@ export const zoomSketch = function (p) {
p.scale(1, -1); p.scale(1, -1);
const frameData = appState.vizData.radarFrames[appState.currentFrame]; const frameData = appState.vizData.radarFrames[appState.currentFrame];
const inverseZoom = 1 / appState.zoomFactor * 2;
// --- OPTIMIZATION: Axes and Ego Vehicle are already in the static background image --- // --- OPTIMIZATION: Axes and Ego Vehicle are already in the static background image ---
// drawAxes(p, plotScales); // drawAxes(p, plotScales);
// drawEgoVehicle(p, plotScales); // drawEgoVehicle(p, plotScales);
if (frameData) { if (frameData) {
drawTrackMarkers(p, plotScales);
drawTrackMarkers(p, plotScales, inverseZoom);
drawRegionsOfInterest(p, frameData, plotScales); drawRegionsOfInterest(p, frameData, plotScales);
if (toggleTracks.checked) { if (toggleTracks.checked) {
drawTrajectories(p, plotScales);
drawTrajectories(p, plotScales, inverseZoom);
} }
drawPointCloud(p, frameData.pointCloud, plotScales);
drawPointCloud(p, frameData.pointCloud, plotScales, 4 * inverseZoom);
if (toggleClusterColor.checked) { if (toggleClusterColor.checked) {
drawClusterCentroids(p, frameData.clusters, plotScales);
drawClusterCentroids(p, frameData.clusters, plotScales, inverseZoom);
} }
if (togglePredictedPos.checked) { if (togglePredictedPos.checked) {
for (const track of appState.vizData.tracks) { for (const track of appState.vizData.tracks) {
@ -291,12 +292,13 @@ export const zoomSketch = function (p) {
const pos = log.predictedPosition; const pos = log.predictedPosition;
const x = pos[0] * plotScales.plotScaleX; const x = pos[0] * plotScales.plotScaleX;
const y = pos[1] * plotScales.plotScaleY; const y = pos[1] * plotScales.plotScaleY;
const size = 4 * inverseZoom;
p.push(); p.push();
p.stroke(255, 0, 0); // Red for predicted p.stroke(255, 0, 0); // Red for predicted
p.strokeWeight(2);
p.line(x - 4, y - 4, x + 4, y + 4);
p.line(x + 4, y - 4, x - 4, y + 4);
p.strokeWeight(2 * inverseZoom);
p.line(x - size, y - size, x + size, y + size);
p.line(x + size, y - size, x - size, y + size);
p.pop(); p.pop();
} }
} }

Loading…
Cancel
Save