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
I have a landscape(generated via Perlin noise) and a ball. I want the ball to move along the geodesic(implementation of basic physics: gravitation, friction).
I thought to do raycast around the ball to the landscape, choose the lowest point and move the ball to this point, but it won't work in every case and it won't allow the ball to jump (with inertia).
So, what is the best way/algorithm to implement such feature?
P.S. I don't want to use any libraries.
It'll take some time, but it's not THAT hard, you need to calculate the ball's new position, ignoring the height field at all (only gravity & inertia) and then, after this step, you check for collisions (basic collision detection between sphere and triangle mesh), and if a collision is detected, generate the collision data and resolve it by applying an impulse OR force in the appropriate direction, using the motion direction and the collision normal direction. Now, if you never worked with collision detection before, it'll probably take you some extra time to learn the algorithms involved, like how to detect collision, how to generate the collision data (normal, penetration, etc).
You need to build your own physics library for this task which individual effort can take months. If you still don't want to export an external engine to your project, At least I suggest you to check open-source engines to see how they handle things.
I can suggest Bullet Physics for a start.
Related
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 5 years ago.
Improve this question
I'm making this game wherein the object should move along a Bezier Curve, I've already computed and successfully drawn the tangent and normal line, but I can't seem to make the Box move along the direction of the tangent. I'm really new in SFML, hope someone could give an advice and direction.
Edited: Like for example, I want to move the object from (0,0) coordinate to (3, 7) when I press only the right arrow key. I know that I should use the concept of vector and normalization but I don't understand the tutorial videos that I watched about it.
There are two parts to this problem, detecting input and then actually moving your object. Presuming you've got the input covered (please say if not) then I'll focus on moving the object:
If an object inherits from sf::Transformable, you will be able to use many transform functions such as setPosition(x,y) and move(x,y) (they do different things!)
A basic example based on yours, using sf::RectangleShape which inherits from sf::Transformable:
sf::RectangleShape shape({5.f,5.f}); // A square, 5 pixels wide
sf::Vector2f movementThisFrame(3.f,7.f); //this would be the value from your curve
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
shape.move(movementThisFrame);
A few things to mention:
You may find using events for input works better, especially if you only want one action per press (isKeyPressed directly queries the key's state, whereas events send you pressed/released events once
move() is relative to the current position, whereas setPosition() is absolute, don't forget that!
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 8 years ago.
Improve this question
I'm getting 3D points from the Kinect via OpenNI. Let's say I have :
X = [93.7819,76.8463,208.386,322.069,437.946,669.999]
Y = [-260.147,-250.011,-230.717,-211.104,-195.538,-189.851]
Z = [958,942,950,945,940,955]
That's the points I was able to catch from my moving ball. Now I would like to be able to compute something like an interpolation or least square with those points to know the trajectory of the ball. I can then know where the ball is going and where it will hit the wall.
I'm not sure of which mathematical tool to use and how to translate it in C++. I've seen lots of resources for 2D interpolation (cubic,...) or least squares, but it seems that it's harder for 3D or I missed something maybe.
Best regards
EDIT : the question is marked as too broad by moderators, so I will reduce the scope with the responses I got : if I use 2D polynomial regression with the 3 plans separately (thx yephick), what can I use in C++ to implement it ?
For what you are interested in there's hardly any difference between 3D and 2D.
All you do is work with planes independently (XY plane, XZ plane, and YZ plane). This will reduce the complexity significantly and allow you to "draw" much simpler diagrams on a piece of paper when you work on this problem.
Once you figured the coordinates in each of the planes it is quite trivial to not only reconcile the coordinates into a 3D space but also provides an added benefit of error checking. For example an X coordinate found in XY plane should match (or be "close enough") to the same X coordinate found in XZ plane.
If the accuracy is not too critical you don't even need to go higher than the first power of polynomial approximation, using just a simple plain-old arithmetical average of the two consequential points.
You can use spline interpolation to create a smooth trajectory.
If not in the "mood" to implement it yourself, a quick google search will give you open source libraries like SINTEF's SISL that have such functionallity.
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 8 years ago.
Improve this question
I'm trying to detect the location of a fingertip from an image. I've been able to crop out a region in the image where it must have a fingertip, and extract the edges using Canny Edge Detector. However I'm stuck. Since my project description says I can't use the skin color for detection, I cannot find the exact contour of the finger, and will have to try to separate the fingertip with edges alone. Right now I'm thinking since the finger has a curved arch shape/letter U shape, maybe that could be used for detection. But since it has to be rotation/scale invariant, most algorithms I found so far are not up to it. Does anyone have an idea of how to do this? Thanks for anyone that responds!
This is the result I have now. I want to put a bounding box around the index fingertip, or the highest fingertip, whichever is the easiest.
You may view the tip of U as a corner, and try corner detection method such as the Foerstner Algorithm that will position of a corner with sub-pixel accuracy, and Haris corner detector which has implementation included in the feature2D class in opencv.
There is a very clear and straighforward lecture on Haris corner detector that I would like to share with you.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm working on a graphics project trying to create an impossible cube in 3D. An impossible cube looks like that:
The trick behind this is two of the edges which are 'cut' and a picture taken from a specific angle to give the illusion of the impossibility.
Well I'm trying to make this but instead of a static image, I want to be able to animate it (rotate around) maintaining the impossible properties.
I have managed to make a cube in blender as you can see in the screenshot below:
I would like to hear your suggestions as to how I can achieve the desired effect. An idea would be to make transparent the portion of the edge that has an edge(or more) behind it, so that every time the camera angle changes, the transparent patch moves along.
It doesn't have to be done in Blender exclusively so any solutions in OpenGL etc are welcome.
To give you an idea of what the end result should be, this is a link to such an illustration:
3D Impossible Cube Illusion Animation
It's impossible (heh). Try to imagine rotating the cube so that the impossibly-in-front bit moves to the left. As soon as it would "cross" the current leftmost edge, the two properties of "it's in front" and "it's in the back" will not be possible to fulfill simultaneously.
If you have edge culling enabled, but clipping (depth-testing) disabled, and draw primitives in the right order, you should get the Escher cube without any need for cuts. This should be relatively easy to animate.
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 1 year ago.
Improve this question
I am trying to build an application which the user can use to draw clothoids with the mouse, i.e. to set the start point and the end point of the spiral and then by dragging these points with the mouse he could also set the shape of the clothoid by modifying the start and end curvature. Probably for changing the curvature I will need to use the tangents though I am not sure of that.
How can one implement that in Qt? Do you know of any example codes that I could run in Qt?
The best approach would probably be to use the Graphics View Framework.
There are a few examples that should help you getting started in the Graphics View Examples page. The Diagram scene one looks like a good starting point for what you want to achieve.
I realize that this is an old question, but for interested parties there is a good discussion of theory and pseudocode for Euler spirals (clothoids) in the paper "Euler Spiral for Shape Completion" by Kimia, Frankel, and Popescu. Sample C++ code can be found online at Brown University's website.
Euler Spiral for Shape Completion
Page with download link for C++ code for method of Kimia, Frankel, and Popescu
Papers by Levien and others suggest methods to improved upon the "biarc" calculation of the paper by Kimia, et al. Levien's paper includes an in-depth history.
The Euler spiral: a mathematical history by Raph Levien
You only need four parameters to draw the spiral: two end points, and the angles of tangents at those end points. (You don't need to define curvature.) The code outputs the intermediate points between the two end points at distance increments of your choice. You simply need to plot and connect those intermediate points.
Once you implement the code, you may need to tweak some of the parameters such as the minimum curvature. You'll likely see a few parameters for which the code "blows up".