How To Create Coordinates In Two-dimensional Grid

Mar 16, 2015

how to create coordinates in a two-dimensional grid, in the end it shall look like A5, F6 and so on. The aim is to place 3 DotComs in this grid by coincidence. To do this one uses two arrays. One array represents one DotCom, the other represents the grid's size, in this case 49 (7x7).The code ends like this:

ArrayList<String> alphaCells = new ArrayList<String>();
...
int x = 0;
int row = 0;
int column = 0;
while (x<comSize) {
grid[coords[x]] = 1; // mark master grid points as used
row = (int)(coords[x] / gridLength);
column = coords[x] % gridLength;
temp = String.valueOf(alphabet.charAt(column));
alphaCells.add(temp.concat(Integer.toString(row));
x++;
}
return alphaCells;
}

why row and column are calculated like this. Furthermore I don't understand why the column is used to generate a character, because columns are marked with numbers and rows are marked with characters.

View Replies


ADVERTISEMENT

Unable To Create A Program For Class Using Two Dimensional Arrays

Dec 6, 2014

I am trying to create a program for class the uses two dimensional arrays. I am stuck on the second step that states Use two parallel arrays. One is a two-dimensional array -- a row of this array will hold six values in this order: [0] number of hours worked, [1] hourly pay rate, [2] gross pay, [3] net pay, [4] federal withholding, and [5] state withholding.

This is what I have so far:

Java Code:

double [][] data = new double [30][6];
String [] names = new String [30];
String str = null;
String detail = null;
int n = input(data, names, inputFile); mh_sh_highlight_all('java');
(there's more but i don't believe it pertains to this question)

My question is how would I create this array. Or, is that right above? I've searched online and in my book and I just don't understand.

View Replies View Related

How To Get All Points In X And Y Coordinates Of Arc

Jul 4, 2014

I am planning a race simulator car and I have a problem to get the x and y coordinates from the graph (or circuit). I explain the problem better. If I for example, drawing an arc using the library DRAW2D how do I get all the points in x and y coordinates of that arc?

View Replies View Related

Release 1 Dimensional Array From 2 Dimensional Array

Mar 13, 2014

I have a 2x2 matrix and a 2 dimensional array.Let's say, my matrix is [a b] and array is [[1, 2], [3, 4], [5, 6],[23, 11]] .I need to multiply each 1 dimensional array in above array with the matrix.For instance,

[1, 2] multiply with [a b]
[3, 4] multiply with [a b]
[5, 6] multiply with [a b]
[23, 11] multiply with [a b]

So, each 1 dimensional array in there will be multiplied with matrix [a b] (same with matrix multiplication).how to do that multiplication in java. But I confuse how to 'release' each 1 dimensional array from the first array so I can do multiplication.How to do that in java?

View Replies View Related

Properties Of A Triangle - X And Y Coordinates

Oct 29, 2014

A triangle is defined by the x- and y- coordinates of its three corner points. Compute the following the following properties of a given triangle: the lengths of all sides, the angles at all corners, the perimeter and the area. The program must prompt a user for the point coordinates. I have created a class Triangle and a class TriangleSimulator, I am stuck and can't figure out why my program won't run correctly.

import java.util.Scanner;
public class Triangle {
Scanner in = new Scanner(System.in);
private int x1;
private int x2;
private int x3;

[Code] ....

View Replies View Related

JavaFX Get Coordinates From Path?

May 8, 2014

I'm working on a project right now in JavaFX, and got stuck. I am drawing a path consisting of CubicCurveTo's and I wonder if there's any way to get the X and Y coordinates from certain parts of that path.

Imagine following a curve (path) with a pencil slowly, and every second you take note the X and Y coordinate. I mean I'm not interested in the control points or start and end points, but the points "in between", preferably at a certain interval.

I've searched for many things online, but have trouble knowing exactly which words to search for. "Paths" often bring up file paths, traversing, coordinates etc. all fail to give me any good results.

I tried to be as specific I could, and I don't think my current code is of any interest in this matter.

(The point of it all is that the path should simulate the path a person walks, and I will store the coordinates in a database for every second).

View Replies View Related

Point Coordinates - X Y Pair

May 8, 2014

What are the x- and y-coordinates of the Points referred to as p1, p2, and p3 after the following code executes? Give your answer as an x-y pair such as (0, 0). Recall that Points and other objects use reference semantics.

PHP Code:

Point p1 = new Point();
p1.x = 17;
p1.y = 9;
Point p2 = new Point();
p2.x = 4;
p2.y = -1;
Point p3 = p2;
p1.translate(3, 1);
p2.x = 50;
p3.translate(-4, 5); mh_sh_highlight_all('php');

P1:

P2:

P3:

My guesses were: P1:(20,10) //Correct

P2:(50,-1) //Incorrect

P3:(0,4) //Incorrect

View Replies View Related

How To Get Coordinates Of Transparent Area In Image

Mar 25, 2015

How to find coordinates of transparent area in the image. I working on .png image which has transparent background and transparent area in the middle of the image. The transparent area in the middle look a like ellipse, so i want to find coordinate of top, bottom, left, and right of that area. I am using opencv.

I have tried to find pixels and from result that i got, i understand that pixel with rgb that equal to 255.0 255.0 255.0 is transparent. what i have in my mind is, if rgb with value that equal to 255 255 255 detected, i will put 1 into arraylist named transparent, and if it not equal to 255 255 255 i will put 0 into the list. So when i look into the list, if there is 1 0 or 0 1 it means that border between transparent area and colored area or vice versa. But, how to know if that border is between transparent area in the middle of image and the image, and not between background and the image. Am i doing this correctly?

Here snippet of code.

Mat imgMask = Highgui.imread(imgfile);
double[] pixels = new double[3];
System.out.println("channel " + imgMask);
for(int x = 0; x < imgMask.cols(); x++) {
for(int y = 0; y < imgMask.rows(); y++) {
pixels = imgMask.get(y, x);

[Code] .....

View Replies View Related

How To Plot Geographic Coordinates In Java

Apr 3, 2014

-7984749.593824852,5368675.690126911 -7984392.035620423,5367570.791302501 -7983220.843257783,5366848.500158152 -7982343.534350842,5364796.5795687605 -7980293.251969412,5363408.488192292 -7980621.978425723,5361760.555707421 -7979175.604281852,5359233.088002191 -7977402.284793513,5358332.850725802 -7976513.843937492,5357665.108234091 -7976472.321767421,5357241.582554582 -7974834.812057852,5357842.933691362 -7973351.925120993,5354420.819505452 -7973743.435770122,5354147.992005592 -7973309.512395002,5352911.428583422 -7973639.9086436825,5352740.575552852 -7972698.034432082,5350359.050518452 -7972255.539456172,5350294.883494262 -7971909.001881332,5349519.720176511 -7970907.683061652,5349775.605440161 -7970575.617020612,5348986.585139751 -7970013.342272613,5349482.445545332 -7969898.683197102,5350177.703443532 -7968337.649977702,5350328.647515352 -7967111.243147633,5351652.264468962 -7966171.150047882,5351373.1018466605 -7966125.286417683,5352115.720678982 -7964626.258154663,5351707.120082232 -7955765.449326492,5345109.379313592 -7954159.443032822,5343966.704795052 -7942364.363746833,5335522.893249432 -7929990.868386692,5326092.063381992

View Replies View Related

How To Draw Points With Coordinates From Database

Jul 23, 2014

I extracted columns from database and made calculations inside while loop. I know i need to make array to get from it coordinates for points. I want to draw them in interface created in another class but i have black hole and don't know how to get datas from while loop to array which is below.

View Replies View Related

Point With X And Y Coordinates - Display Difference Between Them

Apr 26, 2014

//Design/write a class named MyPoint to represent a point with x and y coordinates. The class should contain:

//->Two variables, x and y, that represent the coordinates
//->A no-arg constructor that creates a point (0,0)
//->A constructor that constructs a point with specified coordinates
//->Two getter (accessor) methods for the variables x and y
//-> A method named distance that returns the distance from a point to another point of the MyPoint type
//-> A method named distance that returns the distance from a point to another point with specified x and y coordinates.
//Draw the UML Diagram for the class. Implement the class. Write a test program that creates two points (0,0) and (10, 30.5) and displays the distance between them.

I have written the program but not I have to do it with user input ....

class MyPoint {
private double x;
private double y;
public double getx()
{
return x;
}
public double gety()

[Code] ....

View Replies View Related

Code Is Used To Find Coordinates Of Image

Jan 27, 2015

The code is used to find coordinates of an image and i cannot understand how it works.

for (int y = 0; y < height; y += 2) {
for (int x = 0; x < width; x += 2) {
int px1 = secureRandom.nextInt(4);
int px2 = secureRandom.nextInt(4);
while (px1 == px2)
px2 = secureRandom.nextInt(4);

int px1x = (px1 < 2) ? px1 : px1 - 2;
int px1y = (px1 < 2) ? 0 : 1;
int px2x = (px2 < 2) ? px2 : px2 - 2;
int px2y = (px2 < 2) ? 0 : 1;

View Replies View Related

Buffered Image COORDINATES OUT OF BOUNDS Error

Oct 31, 2014

I am writing a java program that takes a FROM image, a TO image, and a ratio (this is a slide bar in the GUI). Here's my code:
Java Code:

public static BufferedImage rollUp (BufferedImage from,
BufferedImage to,
double ratio) {
BufferedImage finalBufferedImage = new BufferedImage(from.getWidth(),
from.getHeight(),
from.getType());
int packedColor = 0;
for (int r = 0; r < from.getHeight(); ++r) {
for (int c = 0; c < from.getWidth() ; ++c) {

[code]...

So from 0 to 1 (ratio is a double between 0 and 1) the image will "roll up". The effect works completely in the GUI, but the console freaks out at about 0.33 ratio.. This program runs for testing in a class Main and uses a class Splittinimage.. this method is in class TwixPix. When the main class is run, a box pops up with a combo box and a slider. You pick an effect (in this case, roll up) and then slide the slider to set the ratio. The image below those two things performs the effect that was selected. Imagine a PowerPoint presentation slide effect.

View Replies View Related

Using Datagrams - X And Y Coordinates / Send Back And Forth In One String

Feb 15, 2014

Ok, so I am relatively new to datagrams etc. I have three projects set up right now: Client, Client2, and Server, which all interact with each other to send coordinates of player1 and player2 back and forth (X, Y, this is in 2D space not 3D). I have everything set up perfectly except for one problem: I can only send the X coordinate back and forth for each player. I am getting the weirdest error, a parsing error. The way I communicate is I have everything sent back and forth in one string. Then I use the .split() function to turn that string into an array that contains the x and y coordinates. I've done several tests and to no avail. Here's my code:

Server:

Java Code:

package theGame;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import javax.swing.JOptionPane;
public class Main {
static String p1X;
static String p1Y;

[Code] ....

Lines 177 on Client1 and 172 on client2 are where the debugger is saying that I parsed wrong.

Also, if your are going to test this you will need to have the LWJGL libraries in your build path.

View Replies View Related

Coordinates Are Inside Of A Right Triangle On Imaginary Coordinate Plane

May 24, 2014

I'm having a random x and y coordinate generate and I need to check if the coordinates are inside of a right triangle on this imaginary coordinate plane.

View Replies View Related

Transferring Coordinates From Design Program To Array In Java?

Mar 6, 2015

The idea I'd like to present, concerns the correction of "designer" drawings - those done by the design consultants - against "site/construction" drawings - them being used on site by the workers to build the project itself.

This is normally a laborious process, involving being sat at a desk with two large folders, checking each detail and measurement against the design drawing.What I'd like to present is an idea, where the co-ordinates of the design or "mother" drawing, are transferred into a usable Java program, and they could be then used to ensure correct dimensions have been applied by the the sub-contractors in their "construction" drawings.Like I said, this can normally be a process of days for a site engineer to check - process known as "QA, quality assurance".

Basically, I just need to make a presentation of having a genuine interest in Software Design and Development. It could be applied in a range of areas in terms of construction site application - checking drawings, writing up work orders, dig orders etc - but the principle of having the co-ordinates of the mother or "design" drawing scanned into an array in Java as a means to output those site drawings/orders etc, applies to each potential application.

So - in short - and not looking for crystal clear detail, just general pointers - what programs or methods could transfer a plethora of co-ordinates from a design program like Auto-Cad, to a Java program, where I assume I would then be using a program containing a complex series of loops to ensure the correctness of the derived "construction" drawings; derived from the "mother" or designer drawings, that is.

View Replies View Related

Calculate Distance Between Two Coordinates And Determine How Much Of Which Axis To Increment / Decrement

Feb 1, 2015

Basically I'm looking for a way to make one object follow another. For example, if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this?

Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable. In other words I'm just trying to create a homing object.

View Replies View Related

Enter Radius Of Bounding Circle And Display Coordinates Of Five Corner Points On Pentagon

May 29, 2014

(Corner point coordinates) Suppose a pentagon is centered at (0, 0) with one point at the 0 o’clock position. Write a program that prompts the user to enter the radius of the bounding circle of a pentagon and displays the coordinates of the five corner points on the pentagon. Here is a sample run:

Enter the radius of the bounding circle: 100
The coordinates of five points on the pentagon are
(95.1057, 30.9017)
(0.000132679, 100)
(-95.1056, 30.9019)
(-58.7788, -80.9015)
(58.7782, -80.902)

What we know , we know both the radius of the circle(user inputted) and the side of the pentagon from formula (double side = 2 * radius * Math.sin(Math.PI/5)) .We also know that one point is (0 .100) Also i know that the distance between 2 points is Math.sqrt(Math.pow(x1 - x2 ,2) - Math.pow(y1 -y2 ,2)) .

There might be other ways to solve it but this is my best bet trough i dont remember how to solve linear equations of the form x^2 + y^2 = - radius and radius ^2 = x^2 + (y - 100) ^ 2..

The solution i found is using the radius from the center to the point we want to find out and using the radius to the point we already know ( 0 .100) but i have to solve that damn equation first ...

View Replies View Related

Grid Bag Layout / Constraints

Jan 13, 2015

I am making a basic calculator using SWING.I want my JTextField to stretch across the top, above my buttons. All I can seem to get is it be the same size as one of my buttons.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

[code]...

View Replies View Related

Grid Layout Implementation

Mar 13, 2014

How to implement GridLayout. In my applet, I want to make a grid of 2 rows and 2 columns. In each grid I want to add a Label and a TextField. I want the background to be red.

So my code would be?

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class GridLayoutApplet extends Applet implements ActionListener{
// construct components
Label fNameLabel = new Label("First Name");
TextField fNameField = new TextField(20);

[Code] .....

I have read about panels and frames but, it is all confusing to me. How can you add a label and a TextField to one square of the grid?

View Replies View Related

Check Around Cell In Grid

Nov 22, 2014

I am currently trying to write a method for checking to see if an "agent" in a cell (place in a 2d array) is satisfied. So, the assignment is a 2D array that can have a blank space, an O, or a X as a character that fills a particular space. An agent is satisfied if it has similar characters around it in a percentage that is higher than the threshold. For example, if the threshold was 60% and a cell that had an X in it, had 3 X's around it and 2 O's, then it would be satisfied because 3/5>=60%. For my code, I tried using if and else statements to isolate circumstances in the corner of the grid, the edges, and everything in between.

public static boolean isSatisfied(char[][] tissue, int row, int col, int threshold){
char check= tissue[row][col];
if (check==' '){
return true;
}
else{
int countx = 0;
int count = 0;

[Code] ....

View Replies View Related

Calculator Grid Layouts

Aug 19, 2014

So I'm making a calculator using JFrame and that stuff and I need figuring out the GridLayouts. I'm not doing this for homework or anything just for fun. I don't need all the grid layouts.

View Replies View Related

Binary Search - Get To Int X Int Y In A Grid That Is N By N

Sep 15, 2014

The point is to use a binary search to determine how many steps it would take to get to int X, int Y in a grid that is N by N. Picture a parking lot that is square and your car is at (x,y). You can honk your horn from your key to determine the direction of the car. I need to return the amount of steps to get to the car. You can't step diagonally. I am currently getting an error that causes an infinite loop and I can't fix it.

public class ParkingLot {
public int search(int N, int X, int Y) {
int minX = 0, maxY = N, minY = 0, maxX = N;
int num = 0;
int curX, curY;
int newCurX, newCurY;
curX = (minX + maxX)/2;
curY = (minY + maxY)/2;
while (curX != X || curY != Y)

[code]....

View Replies View Related

Diamond In A Square Grid Of Dots

Nov 14, 2014

I am new to java and i am trying to make a Java application which prints a diamond in a square grid of dots whose side length is input to the application.When you run the code is should be like this:

..*..
.*.*.
*...*
.*.*.
..*..

My java code print this:

..*..
.***.
*****
.***.
..*..

Here is my code:

class Main {
public static void main(String args[]) {
System.out.println("#Enter size of Diamond :");
int longestRow = BIO.getInt();
for(int row=1 ; row<=longestRow ; ++row)

[Code] .....

View Replies View Related

How To Make Grid For Battlefield Game

May 27, 2015

I wanted to know which RAD TOOL should I use to make the grid. I used the label but it's not interesting like the game *. I m starting to make the game and can't think how to make the grid.

Thought of using the buttons but can't add image to it.

what should I use to make the grid.

* what I did earlier Is place 9 label in grid form (just to test) and nine buttons one for each. When u click a button, image is shown in respective label... But it doesn't feel like u r playing game..

View Replies View Related

Can't Change GridWorld Grid During Runtime

Jun 5, 2014

I have a question about updating a grid during runtime in GridWorld. I'm making a game called Flood-It (basically, you click on squares to change their color and attempt to get all of the squares the same color in the grid) and I'm having trouble with changing the grid size. I made my own world class, called CellWorld.

import info.gridworld.actor.*;
import java.util.ArrayList;
import info.gridworld.grid.Location;
import java.awt.Color;
import javax.swing.JOptionPane;

[code]...

Now, let me narrow down the issue. It is in the runner class:

world.setGrid(new BoundedGrid<Actor>(world.getLength(),world.getWidth()));

Whenever a user wants to change the grid size after playing the game, this is supposed to set the grid to the new updated size, but it never changes in the actual game, i.e. the user just won a 2x2 game, attempts to change the size to 10x10, but the grid stays 2x2. By debug testing, I can say for certain that everything else works, such as the maxStepCalc and loading the grid. The only issue is the new grid not showing up.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved