Created
July 18, 2019 19:22
-
-
Save dannycallaghan/fd5145278b59dbfaaee9400792dcb570 to your computer and use it in GitHub Desktop.
601-2-97128180-8018788
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Officer: 8018788 | |
CaseNum: 601-2-97128180-8018788 | |
Case 601 - Murdering Again - stage 3 | |
Now murders are beginning to occur. | |
If we can place her near any of the recent crime scenes in the area we should be able narrow down her location. | |
In the setup function, use a for loop to graph all of the points on the map | |
where she was last seen using blue stroke vertexes | |
In addition, we've assembled a list of recent crime scenes in the area. | |
Using another for loop, you should graph those points on the map using yellow fill triangles | |
This time we need to test for any correlations: | |
If she was within 87 pixels of any of the crimes then the details | |
should be appended to possible matches with the following format. | |
{ crime:{x: 0, y:0, victimName: "John Doe"}, suspect:{x: 0, y:0} } | |
Note that the possible matches are already being drawn. | |
Your job is to fill the array with the correct data. | |
For this mission you will need ONLY the following: | |
- for loop | |
- dist() | |
- if() | |
- stroke() | |
- beginShape(), endShape(), vertex() | |
- fill() | |
- triangle(x, y + 7, x - 7, y - 7, x + 7, y - 7) | |
*/ | |
var countyMap; | |
var possibleMatches = []; | |
var suspectPoints = { | |
coordinate_x : [639, 681, 712, 756, 715, 701, 753, 815, 795, 788, 781, 768, 750, 732, 714, 695, 693, 654, 624, 594, 555], | |
coordinate_y : [288, 286, 293, 310, 368, 425, 436, 468, 506, 497, 486, 489, 500, 506, 514, 531, 552, 523, 500, 484, 474] | |
}; | |
var crimePoints = { | |
coordinate_x : [409, 443, 465, 709, 695, 652, 641, 119, 114, 90, 76, 615, 349, 456], | |
coordinate_y : [446, 419, 548, 552, 421, 268, 306, 344, 359, 490, 516, 741, 796, 770], | |
coordinate_names: ["BRIDGET BROADVIEW", "LINETTE MOHWAWK", "JAUNITA JOYER", "LAKESHA SYMMES", "BRAD SILVEIRA", "LIANNE COURTWOOD", "LESLEY MONKSFORD", "JENIFFER DEAUVILLE", "LAVERNE JACQUELIN", "LARRAINE PEGORD", "MAJORIE JENI", "JULIANA ADVERSANE", "HANG NIEMELA", "TAMICA MAUBERT"] | |
}; | |
function preload() | |
{ | |
countyMap = loadImage("map.png") | |
} | |
function setup() | |
{ | |
createCanvas(countyMap.width, countyMap.height); | |
image(countyMap, 0,0); | |
//add your code below here | |
for (let i = 0; i < suspectPoints.coordinate_x.length; i++) { | |
var suspectPositions_x = suspectPoints.coordinate_x; | |
var suspectPositions_y = suspectPoints.coordinate_y; | |
strokeWeight(5); | |
stroke(0, 0, 255); | |
beginShape(POINTS); | |
vertex(suspectPositions_x[i], suspectPositions_y[i]); | |
endShape(CLOSE); | |
} | |
for (let i = 0; i < crimePoints.coordinate_x.length; i++) { | |
var crimePositions_x = crimePoints.coordinate_x; | |
var crimePositions_y = crimePoints.coordinate_y; | |
var crimePositions_name = crimePoints.coordinate_names; | |
strokeWeight(0); | |
fill(255, 255, 0); | |
triangle(crimePositions_x[i], crimePositions_y[i] + 7, crimePositions_x[i] - 7, crimePositions_y[i] - 7, crimePositions_x[i] + 7, crimePositions_y[i] - 7); | |
for (let t = 0; t < suspectPoints.coordinate_x.length; t++) { | |
if ( | |
dist( | |
suspectPoints.coordinate_x[t], | |
suspectPoints.coordinate_y[t], | |
crimePositions_x[i], | |
crimePositions_y[i]) < 87 | |
) { | |
possibleMatches = possibleMatches.concat([{ | |
crime: { | |
x: crimePositions_x[i], | |
y: crimePositions_y[i], | |
victimName: crimePositions_name[i] | |
}, | |
suspect: { | |
x: suspectPoints.coordinate_x[t], | |
y: suspectPoints.coordinate_y[t] | |
} | |
}]) | |
} | |
} | |
} | |
// code to draw the matches ( if any) | |
for(let i = 0 ; i < possibleMatches.length ; i++) | |
{ | |
stroke(127); | |
strokeWeight(3); | |
line(possibleMatches[i].crime.x, possibleMatches[i].crime.y, possibleMatches[i].suspect.x, possibleMatches[i].suspect.y); | |
noStroke(); | |
fill(127); | |
text(possibleMatches[i].crime.victimName, possibleMatches[i].crime.x + 15, possibleMatches[i].crime.y + 15); | |
} | |
} | |
//We are not using the draw function this time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment