Polar equation of a line between two points
I am trying to make a method to output the points (in polar coordinates (r, theta)) along a line between two given polar coordinates.
This will mimick the path of an object traveling across a radar screen.
Is this possible?
Java does not plot in polar coordiantes, you'll have to convert to rectangular to get a plot. If you're just doing a sweep on a screen, then it's fairly simple to do:
r is the radius of your screen,
(0,0) is your Origin translated as (Xmax/2, Ymax/2)
when you draw the line you just start at your Origin and get your end values as
X1=X0+r*cos(Theta) and
Y1=Y0+r*sin(Theta),
I've not seen, nor do I think there is any other support to do what you want--you have to convert to (x,y) coordinate system.
This will leave a ragged edge so make a border around your screen.
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
public class JRadar{
public JRadar(){
JPanel p = new MyJPanel();
JFrame f = new JFrame("ForumJunk: JRadar");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(p);
f.pack();
f.setVisible(true);
public static void main(String[] args){
new JRadar();
class MyJPanel extends JPanel implements ActionListener{
Timer t = new Timer(10, this);
Dimension d = new Dimension(512, 512);
BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
double theta = 0;
int r = d.width/2 - 16;
Point origin = new Point(d.width/2, d.height/2);
public MyJPanel(){
g.setColor(Color.RED);
this.setPreferredSize(d);
t.start();
public void actionPerformed(ActionEvent e){
g.clearRect(0, 0, d.width, d.height);
g.drawOval(16, 16, 480, 480);
g.drawLine(origin.x, origin.y, (int)(origin.x+r*Math.cos(theta)), (int)(origin.y+r*Math.sin(theta)));
theta += 0.01;
if(theta>=Math.PI*2) theta = 0.0;
repaint();
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(bi, 0, 0, this);
}Edited by: morgalr on Mar 3, 2010 4:59 PM: code example added
Similar Messages
-
Suggestion to draw a line between two points...
I have the XYZ position of 2 points, I would like to draw a line between those points. I have tried with a cylinder and it did not work as I expect...I guess a better method exist in Java3D... Do you have any suggestions??
thanks
Petetry the LineArray class.
-
Shooting mouse cursor beyond intended straight line between two points.
I copied this forum question from Lightroom, and I hope this is ok because I did not know how to express the problem I am experiencing:
"The photoshop brush tool interprets shift-click as a brush stroke that connects the previous brush mouse-up position with the current mouse-down (the shift-click) as a straight line stroke.
[My experience is that every so often, maybe every three or four "shift-clicks" to get my mouse to create a straight line to my next placed mouse position, the Mouse goes Wild, and shoots way beyond my intended next position, and depending on how zoomed in on the image i am, I frequently loose my place where I had been working. It becomes quite frustrating as this is a very frequent occurrence. I have heard others with this version CS3 as well as CS2 having the same "shooting Cursor" which is accompanied by some cursing of my own. As said below, Time savings is the reason for this technique. If this problem has been dealt with already, I am sorry to have clogged up the forum, but please re-direct me with the key words to find that thread. How do I cause this shooting cursor to stay within my mouse placement?]
I find this a HUGE time-saver in creating masks as it doesn't require that I have a steady hand. I'm frustrated that LR does not offer the same capability. This feature would complement the auto-mask feature (kinda works). I could create a mask in a fraction of the time if LR included this feature.
Another irritation of occurrence is when setting lines from the rulers, the image will suddenly zoom in by a small amount. In other words, there are several areas where the software seems to have a mind of it's own, and behaves in an erratic fashion not at all related to the intended action and result.
I am operating a Mac 10.5.7
Model Identifier: MacPro3,1
Processor Name: Quad-Core Intel Xeon
Processor Speed: 2.8 GHz
Number Of Processors: 2
Total Number Of Cores: 8
L2 Cache (per processor): 12 MB
Memory: 2 GB
Bus Speed: 1.6 GHz
ATI Radeon HD 2600 XT:
2x2.8 GHZ Quad-Core Intel Xeon
2 GB 800 MHz DDR2 FB-DIMMThanks for your quick reply. I am attaching screen shots of my
current mouse setting, and a graphic of how the behavior is
demonstrated. The image is one in which quick mask is being used to
create a selection, and I am using the paint brush and find it easier
to use the brush with the technique of clicking the brush at one point
then holding the shift key while I click the brush at the desired next
point which should allow the brush to paint a straight line between
the two points. The technique works for 3 or 4 clicks, when at the
next click, it is as if it was just shot clean out of the realm of the
desired area. It is almost funny, except that this is a technique I
find most useful and frequently helpful, and is not confined to the
paint brush, but the eraser as well. This does occur also with my
computer at work, a pc, and a Microsoft mouse. I have been using
Photoshop for 12 years, and this problem did not start until I started
using CS3 extended. We have upgraded two HP pcs at work to CS4
extended, and each uses a different mouse, and both exhibit the same
behavior as experienced by other persons working at those stations,
and while using Photoshop.
I do hope you could look into this a bit further, Mark, as my
explanation of the problem may not be clearly presented for you to
fully understand just what I am experiencing.
Thank you for your help.
Fred -
Drawing a squiggly or wavy line between two points?
I've searched and searched and cannot find a way to draw a
squiggly or wavy line in the MOUSE_MOVED event as the user clicks
and moves the mouse.
How can this be done??if you don't want a direct line from one mouse position to
the next, you won't want to use a mousemove event. use a timer
event that checks the mouse position periodically and with each
check start another timer event that executes much more rapidly and
draws a line with perturbations (say, a sine curve) from one mouse
position to the next. -
This may be an obvious question to more experienced users, but I can't seem to find anything on it in the documentation.
Is there any way to find the bearing of a line segment, that is, the angle between due north and the line between two points? It seems so simple, and Spatial provides a function to find a point at a specified distance and heading from another, so it seems like existing functionality.
Thanks in advance - JUpgrading to 11g is one option.
The other option is to write this function in PL/SQL yourself if you don't need a very accurate solution.
This web page here gives a simple algorithm to find the bearing for two points.
http://www.movable-type.co.uk/scripts/latlong.html -
hi
i have a code like this
trendline.jsp
<%@page import="ChartDirector.*" %>
<%
// The data for the line chart
double[] data = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
59, 73, 77, 84, 82, 80, 91};
// The labels for the line chart
String[] labels = {"Jan 2000", "Feb 2000", "Mar 2000", "Apr 2000", "May 2000",
"Jun 2000", "Jul 2000", "Aug 2000", "Sep 2000", "Oct 2000", "Nov 2000",
"Dec 2000", "Jan 2001", "Feb 2001", "Mar 2001", "Apr 2001", "May 2001",
"Jun 2001", "Jul 2001", "Aug 2001", "Sep 2001", "Oct 2001", "Nov 2001",
"Dec 2001"};
// Create a XYChart object of size 500 x 320 pixels, with a pale purpule (0xffccff)
// background, a black border, and 1 pixel 3D border effect.
XYChart c = new XYChart(500, 320, 0xffccff, 0x000000, 1);
// Set the plotarea at (55, 45) and of size 420 x 210 pixels, with white background.
// Turn on both horizontal and vertical grid lines with light grey color (0xc0c0c0)
c.setPlotArea(55, 45, 420, 210, 0xffffff, -1, -1, 0xc0c0c0, -1);
// Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 8 pts
// Arial font. Set the background and border color to Transparent.
c.addLegend(55, 22, false, "", 8).setBackground(Chart.Transparent);
// Add a title box to the chart using 13 pts Times Bold Italic font. The text is
// white (0xffffff) on a purple (0x800080) background, with a 1 pixel 3D border.
c.addTitle("Long Term Server Load", "Times New Roman Bold Italic", 13, 0xffffff
).setBackground(0x800080, -1, 1);
// Add a title to the y axis
c.yAxis().setTitle("MBytes");
// Set the labels on the x axis. Rotate the font by 90 degrees.
c.xAxis().setLabels(labels).setFontAngle(90);
// Add a line layer to the chart
LineLayer lineLayer = c.addLineLayer();
// Add the data to the line layer using light brown color (0xcc9966) with a 7 pixel
// square symbol
lineLayer.addDataSet(data, 0xcc9966, "Server Utilization").setDataSymbol(
Chart.SquareSymbol, 7);
// Set the line width to 2 pixels
lineLayer.setLineWidth(2);
// tool tip for the line layer
lineLayer.setHTMLImageMap("", "", "title='{xLabel}: {value} MBytes'");
// Add a trend line layer using the same data with a dark green (0x008000) color. Set
// the line width to 2 pixels
TrendLayer trendLayer = c.addTrendLayer(data, 0x008000, "Trend Line");
trendLayer.setLineWidth(2);
// tool tip for the trend layer
trendLayer.setHTMLImageMap("", "", "title='Change rate: {slope|2} MBytes/per month'");
// output the chart
String chart1URL = c.makeSession(request, "chart1");
// include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("");
%>
<html>
<body topmargin="5" leftmargin="5" rightmargin="0">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
Trend Line Chart
</div>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html>getchart.jsp
<%@page import="ChartDirector.*" %><%
try
out.clear();
GetSessionImage.getImage(request, response);
if (Math.max(1, 2) == 2) return;
catch (IllegalStateException e)
response.sendRedirect(response.encodeRedirectURL(
"getchart.chart?" + request.getQueryString()));
return;
%>i have to draw a trendline chart...
i searched for examples...
i come across this. above example..
actually my querry is i ve to draw the trendline between two points.
in between "data" ( 63 to 70) only...
is there any way to do this
please help me
thank you in advance.hi
i tried this..
<%@page import="ChartDirector.*" %>
<%
// The data for the line chart
double[] dataX0 = {6};
double[] dataY0 = {63};
String[] labels2 = {"Jul 2000", "Aug 2000", "Sep 2000", "Oct 2000", "Nov 2000",
"Dec 2000"};
// The lengths (radii) and directions (angles) of the vectors
double[] dataR = {3};
double[] dataA = {60};
// The labels for the line chart
String[] labels = {"Jan 2000", "Feb 2000", "Mar 2000", "Apr 2000", "May 2000",
"Jun 2000", "Jul 2000", "Aug 2000", "Sep 2000", "Oct 2000", "Nov 2000",
"Dec 2000", "Jan 2001", "Feb 2001", "Mar 2001", "Apr 2001", "May 2001",
"Jun 2001", "Jul 2001", "Aug 2001", "Sep 2001", "Oct 2001", "Nov 2001",
"Dec 2001"};
// Create a XYChart object of size 500 x 320 pixels, with a pale purpule (0xffccff)
// background, a black border, and 1 pixel 3D border effect.
XYChart c = new XYChart(500, 320, 0xffccff, 0x000000, 1);
// Set the plotarea at (55, 45) and of size 420 x 210 pixels, with white background.
// Turn on both horizontal and vertical grid lines with light grey color (0xc0c0c0)
c.setPlotArea(55, 45, 420, 210, 0xffffff, -1, -1, 0xc0c0c0, -1);
// Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 8 pts
// Arial font. Set the background and border color to Transparent.
c.addLegend(55, 22, false, "", 8).setBackground(Chart.Transparent);
// Add a title box to the chart using 13 pts Times Bold Italic font. The text is
// white (0xffffff) on a purple (0x800080) background, with a 1 pixel 3D border.
c.addTitle("Long Term Server Load", "Times New Roman Bold Italic", 13, 0xffffff
).setBackground(0x800080, -1, 1);
// Add a title to the y axis
c.yAxis().setTitle("MBytes");
// Set the labels on the x axis. Rotate the font by 90 degrees.
c.xAxis().setLabels(labels).setFontAngle(90);
c.addVectorLayer(dataX0, dataY0, dataR, dataA,1, 0x0000cc
).setArrowHead(11);
/*LineLayer layer1 = c.addLineLayer();
//LineLayer layer1 = c.addLineLayer(dataY0, 0xff3333, "Compound AAA");
layer1.addDataSet(dataY0, 0xff3333, "Close Loop Line").setDataSymbol( Chart.LeftTriangleSymbol, 10);
layer1.setXData(dataX0);
layer1.setLineWidth(2);*/
// Add a line layer to the chart
LineLayer lineLayer = c.addLineLayer2();
// Add the data to the line layer using light brown color (0xcc9966) with a 7 pixel
// square symbol
lineLayer.addDataSet(data, 0xcc9966, "Server Utilization").setDataSymbol(
Chart.SquareSymbol, 7);
lineLayer.setLineWidth(2);
// output the chart
String chart1URL = c.makeSession(request, "chart1");
// include tool tip for the chart
//String imageMap1 = c.getHTMLImageMap("");
%>
<html>
<body topmargin="5" leftmargin="5" rightmargin="0">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
Trend Line Chart
</div>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
usemap="#map1" border="0">
</body>
</html>how can i set the angle of direction for the arrow..
suppose
i wanna draw an arrow b/w these points
y=50 to y=37
how can give the length and direction here
c.addVectorLayer(dataX0, dataY0, dataR, dataA,1, 0x0000cc
).setArrowHead(11);i mean in daraR and dataA...
please help me
thank you in advance -
Getting the length between two points
Hi All,
I am trying to get the distance between two points and came across the SDO_LENGTH function in the manual - however there is no example on how to use it.
I was expecting the following statement to return me the value 9 but instead I am getting errors along the lines of SDO_GEOM.SDO_LENGTH must be declared etc.
=============================================
SDO_GEOM.SD0_LENGTH(
MDSYS.SDO_GEOMETRY(2
,NULL
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
============================================
what am I missing
any help appreciated
Brent GloverI think I have found my answer
============================================
DECLARE
v_length NUMBER;
BEGIN
v_length := SDO_GEOM.SDO_LENGTH(
MDSYS.SDO_GEOMETRY(2
,NULL
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
DBMS_OUTPUT.put_line(v_length);
END;
============================================= -
Hey Everybody!!
I want to draw an arc between two points.. i can't seem to be able to figure the math but i'm sure this is fairly simple and somebody has done this before...
Thanks in advance.that's correct...you need three points to define an arc..
the reason i said two points is that i'm doing a diagram editor and i have to let the user connect pairs of objects using arrow, arcs, lines etc...
any help is greatly appreciated... -
Dont want to show the divided line between two rows in a Grid.
Hello Friends,
I want a Grid in which I want multiple rows but i dont want to show the divided line between two rows.
It is just like a grid on Territories form(Administrator->SetUp->General->Territories)
Thanks.Mithun,
The component you're talking about is not a grid, and that component is not exposed by the UI API so you cannot use it.
Regards,
Vítor Vieira -
Google maps "get directions" between two points stopped working in firefox
When using google maps to find directions between two points "Get Directions" it will just sit there loading... never finishing and showing the routes between the locations.
This used to work fine about a month ago. I have not done anything, expect update Firefox.I can still get the basic directions to work in Google Maps, but recently the 3D driving directions has stopped working, and I'm pretty sure it stopped just about one Firefox update back. I realize this function is gravy to many people - a toy - but for someone who uses visual cues it has been extremely useful for imprinting the information in my mind, familiarizing myself with the route ahead of the drive. When I am traveling without a 'navigator' - a passenger who can read the directions as I drive - this is a huge help. Today I got a message about updating the GoogleEarth plugin, which I did - twice! Still no 3d directions, though suddenly the GG 3d driving simulator works. This has to be a FF problem :-(
-
I am trying to construct an invoice. How can I install a vertical line between two or more underlined lines to create a break. I have tried the insert, shapes and nothing works. If I try any of the functions the whole document shifts to the right and I loose some of the lines. Is there a work around, or is I work not able to do what I want?
Thanks
ArmandIt sounds as though you may have "Object Causes Wrap" activated for the Line Shape. This will push other content away.
See the Wrap Inspector.
Jerry -
How do you find the average value of all the data between two points on a single channel
I am tring to calculate the average value of all the data points on a single plot between two seperate points
I have attahced an illustration.
Tim
Solved!
Go to Solution.
Attachments:
plot.jpg 173 KBHey smoothdurban,
I've seen Brad's code, and trust me, it's worth the effort to let him help you get it up and running - it's definitely the most ideal way to solve this problem. However, as Brad said, there are multiple ways to tackle this - both interactive and programmatic - so in the meantime, I'll take a second to detail one of the interactive and sure-fire ways to find the average of data between two points on a single channel.
We'll use"Flags." Set up your VIEW graph exactly as you did on your original screenshot, using Band Cursors to approximate the beginning and ending X-values representing the range you want to examine. Next:
1. Click the "Set Flags" button () that is a part of your 2D Axis System. Note that you can hold down the Shift button if you ever decide you want to do this on more than a single curve at one time.
2. Select the "Flags: Copy Data Points" button that enables after Flags are set.
3. This creates new channel(s) in the default (bold) group in the Data Portal that contains only the Flagged data.
4. Select DIAdem ANALYSIS.
5. Select Statistics » Descriptive Statistics.
6. In the Channels input, select the newly created channel containing your Flagged Y-Data.
7. Ensure that the Arithmetic Mean parameter is set. You can preview the data and the result in the dialog before pressing OK to execute the calculation.
You may have noticed that in the Descriptive Statistics calculation, one of the parameters that you can set is the range of channel rows to operate on - so, if you know the row numbers of your beginning and ending X-values, you could just simply run the Descriptive Statistics calculation and use this parameter to operate on a row subset of your original channel instead of the entire channel.
Derrick S.
Product Manager
NI DIAdem
National Instruments -
How to measure distance between two points uisng uiaccelerometer
Hello all,
I am trying to measure distance between two points.So for that i am used uiaccelerometer but its give only rotation changes. I am moving my whole device from one point to another point so for that all x,y & z changes remain same. So how can get the device movement for that?
Thank you..UIAccelerometer does not give rotation changes, it senses acceleration in each of the 3 axis in g-force units. Moving in a plane from one point to another and stopping will result in a net g-force in that axis of zero. To get distance one has to measure the initial acceleration and then the time before a deceleration is detected. It gets really complicated in real life since the start and stop are not instantaneous.
-
How to remove line between two raws in word template designing ?
Hi everbody,
Hope you are doing good.
i am designing report in word template.
i wandoring how to remove line between two raws ?
currently it gives me lines between each single raw.
i want to remove line between two raws.
any help is greatly appreciated.
Thanks.Hi,
are the rows inside a table-structure? Perhaps the line are the borders of the table?
Regards
Rainer -
Switching lines between two accounts.
How possible is it to switch lines between two different accounts i have to accounts with five lines and i would like to switch a number from one to another and one back. i.e. Number 123-456-7890 from Account A with Number 0987-654-321 from Account B.
hey i am on my grandma plan but i have my own how can i switch that account that i have on my grandma to mine
Maybe you are looking for
-
As of late, i have purchased a new airport, and since then my connection has gotten worse and worse. When i take my computer out of sleep its at 4/4 bars. the second i press my AOL instant messenger or my firefox browser, it decreases to 2 and someti
-
Does 10g application server 10.1.2.0.2 work for 9i database?
I have installed 9i database on UNIX. then I am trying to install 10 application server 10.1.2.0.2. But somehow it force me to install a complete 10g database, which is undesireable for me. So I just wonder whether 10g application server can work for
-
Revision: 15581 Revision: 15581 Author: [email protected] Date: 2010-04-19 17:14:00 -0700 (Mon, 19 Apr 2010) Log Message: Better coding style and some comments for the previous code submission. Modified Paths: osmf/trunk/apps/samples/framew
-
Need one more field in VENDOR Master.
Dear Gurus I need to Change the vendor name, But old name should be existed in system. For this i need to add text field to enter the New name and date of change, Is there any option in Vendor master. Request you to suggest. and what is the path
-
I restored my daughters ipod to factory settings after she forgot her password. Now imessage is not allowing me to use her email address, and it tells me it is use on another device. Help!