Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Adding Radar sweep line to code.

$
0
0

I am building a weather radar based on Grook.nets code for an ultrasonic sensor, however, I am not using a ultrasonic sensor. I have modified the code in many ways... The radar currently can detect heavy rain/hail at about 40 mi. I would like to add a sweep line for effects on the screen. Could anyone help me out? I am attaching my code. Thank you.

import processing.serial.*; Serial port; Serial port2; String data = ""; String Radius = ""; String Theta = ""; int index = 0; float distance = 9000; float angle = 10; float pi = 22.0/7;

PImage img;

void setup() {

size(1000,800); background(100); ellipse(500,500,1000,1000); line(500,0,500,1000); line(0,500,1000,500); line(500,500,1000,0); line(500,500,1,1); img = loadImage("MAP3.png"); tint(255,1); } {

port = new Serial(this, "COM3", 9600); port.bufferUntil('.'); }

void draw()

{ image(img, 0, 0);

}

void serialEvent(Serial port) {

data = port.readStringUntil('.'); data = data.substring(0, data.length() - 1);
index = data.indexOf(","); Radius = data.substring(0, index); Theta = data.substring (index+1 , data.length());

translate(500,500); point (1,1);

  distance = float(Radius);
  angle = float(Theta) /180 * pi;
  fill(10,600,20);
  ellipse(distance * cos(angle) ,  -1 * distance * sin(angle) , 40,20);

fill(98,245,31);

// simulating slow fade of detected precipitation until next elevation sweep. noStroke(); fill(8,3); rect(1000, 1, width, 1010);

fill(98,800,31);

}

Thanks for any help. Initial code written by Grook.net. Modified by Tim Herrman.

Here is a link to an image showing what I want to do.

http://www.bing.com/images/search?q=Radar+Sweep&view=detailv2&&id=22EB8F2D6B4A7022F64E3C9B07F1499647F2F8D1&selectedIndex=23&ccid=3s8XPcDD&simid=608046625551091599&thid=OIP.Mdecf173dc0c37904ea95e802d6180293o0&ajaxhist=0


Viewing all articles
Browse latest Browse all 2896

Trending Articles