Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a way to add an arrow head to a cubic curve? I can think of a very tedious way to do it (adding a shape, and control its direction, etc). But I am hoping there is a cleaner solution.
I seriously doubt that this is a built-in functionality in javafx, and your best bet would be to make a simple polygon arrow head and size it to the size you want, and then 'anchor' the middle of one of the sides to the end of the spline. If you make an equilateral triangle you'll save yourself some sadness. Also, to make sure the direction is correct all you'd have to do is to make sure that the part of the line connecting to your triangle is perpendicular to the base of the triangle, then it'll always be pointing in the 'correct' direction.
An example of the polygon creation for a triangle would be:
Polygon polygon1 = new Polygon(new double[]{
45 , 10 ,
10 , 80 ,
80 , 80 ,
});
That makes a a basic red one. :) good luck!
I found another simpler workaround (2 steps):
Add a polygon shape (triangle) in the node which is supposed to
receive a curve. Have this triangle place in the location where the
curve's end point will be set.
Then, set this triangle to visible when a curve is drawn and to not
visible when the curve is deleted.
It is not perfect, but look good and does the job!
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm fairly new to OpenCV Java and I've been looking for methods to do what the title asks.
So far, from what I understood, the first step should be to use a detecting edges filter like Sobel or Laplace.
Coming from https://docs.opencv.org/3.4/d2/d2c/tutorial_sobel_derivatives.html, I get the following result : glass_sobel
From now on, I don't know what to do next... What should I do to get what I want ?
Thanks for your help !
Taking the vertical edge difference (sobel) is indeed the right step. But first I suggest fixing some parameters. For instance, is the position, size and shape of the glass fixed? then take an image without fluid and use that to extrapolate the glass from the result. If not, I would take the following steps:
Try to increase edge visibility. In your image you do see a clear edge, but the computer might see this as 4 edges, therefore try to make sure edges close to each other are seen as one edge (dilate operation might do that). Depending on the liquid, you could alternatively extract a certain color from the image. Water is here the most unfortunate case, but something as orange juice is easily detected.
With the more clear edges, I would try to get a vertical line out of the glass, and classify each edge (is it part of glass or part of liquid).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Contex: I'm trying to make a 2d physic engine, i'm starting to think about how to draw shapes that i could rotate. So i thought i could draw irregular shapes by drawing lines from several equations of straight. Now i have some doubts:
There is a easy way of draw a straight by giving an equation?
There is a library that can help me to handle equations?
The reason to use equations instead of using functions to draw lines from x1,y1 to x2,y2 is that i want the equations to calculate collisions between shapes.
Do you know a book or an article that could help me pull this off?
I'm gonna work in java, for now this is just an idea.
Not an expert in this field but quick search on java 2d engine collision engine returns dyn4j library on the first page. You can explore their examples and consequently the implementation code.
https://github.com/wnbittle/dyn4j
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am currently working on a project for my java class where I have to make a method to take in a circle that is being called an "Animal" as an argument.
With this argument I then have to return a boolean value indicating whether or not the two "Animals" overlap. Note: To know if the circles are overlapping, there centers must be less than one radius apart. I'm not really sure how to start this and whether or not I should be using an if statement or not. Any and all help would be greatly appreciated.
The logic behind the math and geometrical figures is very interesting, you can find more things to learn [here][http://mathworld.wolfram.com/]:
In your case, 2 circles, no matter is they have different radius, they intersect if and only if the distance between their centers is smaller than sum of their radius
take a look at the illustration if you need a graphical reference..
Code:
you need the center of the circle and the radius, with just that you can geometrically create a circle, then:
create a method that returns the distance between 2 points
and call it by passing as parameter both centers of the circles,
the rest is subtraction and there is the logic that return the boolean you need.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
QUICK RECAP OF THE PROJECT:
I'm making a car that would drive itself in between the obstacles of which picture will be taken by your phone. The picture should then be cropped to the size of the "area of movement" or the area where car can move. That should have been done automatically. In my case I’d do it like this:
Before you would take picture of the "obstacle map", you would have to put a paper sheet on the ground, so the program would recognize the size of the area/the way image should be transformed to be "perpendicular" to the ground.
In program you would mark the area where car can move and it would crop it. Then it would automatically transform the selected area to be as "perpendicular" as possible, so the obstacle map would be good enough for the car to move in it as it would be an obstacle map.
Then I have 2 options: either to automate obstacle recognition or to make it manual. If I would automate it, I would have to use some sort of OpenCV obstacle recognition. Else id just make a simple program for marking obstacles. After that you would mark a point, where the car should move to and it would calculate the most optimal path with A algorithm. This algorithm only gives the points where the car should move, so I connected with some professors in my school and they are now doing some help with steering of car and calculating the right angle the car should steer to come to certain location.*
I have 2 questions, both connected with BufferedImage.
Two questions back in the past, I asked how to get a sub image that is defined by 4 random points. I got no answers for doing that so I did it myself, but I know that this method is VERY INEFFICIENT and I'd like to know how can it be done better?
My second question is about matrix transformation. I have already been discussing about that and got this code which is basically a modded version of this one. The code is limiting me to the size of the input bufferedimage and i'd like to know how can I "remove" this limit, because in some cases the image needs to be upscaled, but the code keeps cropping it. Also I’d like to have some sort of AA (Anti Aliasing) on it, because the transformed image just looks weird/pixelated.
EDIT: In first question's code, there is a method line(Point p1, Point p2) in class Place_2D which basically creates an arraylist of points connecting 2 points in place, creating a line.
Antialiasing will be achieved by a better sampling scheme than nearest-neighbor. You will get a nice improvement by switching to bilinear interpolation.
Every back-projected point falls between four pixels. The fractional part of the coordinates allow you to compute mixing weights to be assign to the color values of these four pixels.
If the scaling factor is small (transformed image being less than a quarter of the original), you can blur the image beforehand to avoid other artifacts.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a cube and 4x4 transformation matrix Cube is rotated randomly I need to find the nearest face of cube regarding to camera and rotate the cube by aligning that face to the camera.
How can I do that. Thanks in advance.
Without getting into a bunch of math, here is a strategy.
Identify the face nearest to the camera under some criteria. Two possible criteria for determining the closest face are:
a. Finding the closest face based on the Euclidian distance between the face centroid and the camera's centroid.
b. Determine which face normal vector is most close to parallel to the camera view vector and has a direction that is opposite to the view vector. This assumes that the face normal vectors point outwards.
Once you've identified the 'closest' face, determine the inverse transform to that will align the face normal with the camera view vector. Any decent 3D computer graphics text will serve as a reasonable guide.