Draw arrow connected to rectangle in Java [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am trying to create an image that contains nodes (represented as rectangles) and a path. Two consecutive nodes in the path should be connected with a directed edge (line and an arrowhead at the end). Each line should start at the center of a rectangle and point towards the center of the next rectangle in the path.
The question is whether there is any easy way to calculate the point where each arrow hits the rectangle. Rectangles are not necessarily aligned horizontally and/or vertically, so this is not trivial.
I have managed to come up with a solution that works quite well, but I had to remember all the geometry I was taught at school. Maybe there is an easier way to do it with rotations, instead of calculating directly the end point?

In this example, the endpoints coincide with the centers of the connected rectangles; this obviates the need to calculate the intersection explicitly.
A similar approach is taken in the example cited here, using symmetric shapes.

Related

Additive White Gaussian Noise Java in dB [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am trying to add AWGN to my audio file. I convert my wav file to byte array. I am trying to add 10dB AWGN to this array. In matlab there is imnoise which adds AWGN to image. In java is there any library? Thanks in advance.
If you actually need the additive Gaussian white noise output similar to that of Matlab's imnoise function, this is the extent of the code that you need to implement in Java:
B = A+MU+STD*randn(size(A))
where A is your input data, B is your output of the same size, MU is the mean of the noise, and STD is the standard deviation. Independent and identically distributed (IID) Gaussian white noise is added to each component of A. This calculation needs to be done in floating point (as many of Matlab's image processing routines are).
The randn function produces normal random variates. You can use java.util.Random.nextGaussian() to produce these. If you need some extra speed, try a Java implementation of the Mersenne Twister algorithm.
Not sure if i got the question correctly. Ist that the thing your are looking for and then just regulate the db over whatever player you are using?

Java rotating counterclockwise 90 degrees [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
If I have a 2x2 image (with the following pixel colors below), and am rotating the pixels counterclockwise by 90 degrees, what would the new arrangement be?
{Pixel.BLACK, Pixel.BLUE},
{Pixel.RED, Pixel.GREEN}
I know this is a simple question, but my test case keeps on failing and I am guessing that perhaps my logic may be incorrect.
BLUE, GREEN
BLACK, RED
If your coordinates were rows.

about preparing the map of Risk game with swing in java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
i want to start coding a game project which is called "Risk" and my first aim is build the map correctly. So logically, each territory should be a JButton but JButton's are rectangular oriented. Moreover, i know that every territory should be a component so i can use mouse event listeners for each of them. well my question is
should i try to draw each territory with using coordinates, lines, shapes etc ? or
is there any way to draw and combine each territory regularly ?
On the other hand, this is the link for the map of the game.
Map of Risk
try to make fixed territories, so you mustn't have headaches with resizing your actual territory, only change the color of the territory you occupied recently, like in Dune2 was, if you know that game. And I think, definitively you should, and put that jbutton under the numbers on your map (or what will be definitively better, if you replace numbers with territory name and you'd put that button under that). I hope, my answer answered your doubts :)
I feel like it's going to be a lot of work. The easy way out would be to just put JButtons under the numbers.
If you still feel inclined to make irregularly shaped clickable areas, I suggest creating instances of Polygon (java.awt) for each country. They are made using arrays of x and y points that define the corners. Conveniently enough, there is a Polygon.contains(x, y) method that lets you know if (x, y) is in your polygon. If you use a larger JPanel that covers the entire map and get the mouse location relative to the JPanel, you can notify each country whether or not the mouse is inside it.

Why do some languages use a flipped Y axis? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In Actionscript and 3D systems, the Y axis increases upwards (bottom is either 0 or -1, and top is usually 1). This convention makes sense relative to the real world. However in languages such as Java, the convention is flipped (bottom is 1, and top is 0 or -1). I've always wondered: Why?
Thanks! :)
In 2D software, the y-direction is typically downwards - top left corner of the screen is the origin. The first screens were text only, and you would number text lines from the top. This numbering system stuck.
In 3D software, many libraries choose to implement Y as up, but only because, as you've mentioned, that "makes more sense".
This is not a feature of the "language". It's a feature of the library.

Neural networks for a 3d space value linked list matching in java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am trying to match a prerecorded 3d(float x, float y, float z) linked list to another 3d linked list(float x, float y, float z). There is about 50 prerecorded sequences with 1000 examples of the same move every time, against which I am trying to match through.
The size of linked lists highly vary.
Is there a specific neural network pattern/library/framework/algorhytm in Java I could use for this task ?
Any suggestions would be highly appreciated!
Waiting for your replies)
If you insist on a neural network...
Simplify your prerecorded input
For each 3d point list create 3 black and white 2d images of your points (drawing a line between each adjacent point)
Top-down (x,z)
Forward-back (x,y)
Left-right (z,y)
Simplify your user input
Create the same 3 black and white images (explained above)
Find the bounding box of the points and scale the image to a uniform size
Having your user input, scaled to same size as your prerecorded input will facilitate recognition
Create neural networks for image recognition
Create a trained network for your prerecorded (3 images for each)
This seems like it would work http://neuroph.sourceforge.net/image_recognition.html
Build your neural nets from the black and white images (that represent the 2d mapping of your 3d points onto the 3 perpendicular planes)
Experiment with your matching bounds/constraints
IF Top2Bottom >= 0.75 AND Forward2Back >= 0.75 AND Left2Right >= 0.75
THEN IsAMatch = True
ELSE IsAMatch = False
I would probably just generate a large 3d corridor (think wide 3d tube, or a collection of connected cylinders) that represented the extremes of my prerecorded points then scale the user input points then check if the user input points fall within the matching corridor.
EDIT Very odd that the question itself was down-voted and closed, then days later my answer was down-voted. Realistically, the question was likely closed due to a failure of group think on the part of the moderators. Maybe it then looked a little awkward to have a closed question with a +1 "Accepted" answer, so this answer was subsequently down-voted (twice).
From my experience, the only way to ask a question like this is to either slap a large bounty on it, or re-word it in a way that won't offend the fragile sensibilities of the moderators (most of the time they do a good job and don't overstep...).

Categories

Resources