Find the length of a curved line in Matlab [closed] - matlab

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 have a skeletonized binary image.
The image contains curved lines.
I want to be able to find the length of a line (number of pixels) between any two point (on the line of course).
How can I do it (in Matlab)?

Here is one approach for simple situations (where there are no loops etc, and your line is only a pixel wide)
Start at the startpoint, define as currentpoint and mark as visited
Go to an unvisited neighbor point of the currentpoint
Increase count by 1, mark as visited, define this point as currentpoint
If you reach the endpoint, stop. If you still have univisited neighbors, goto 2. If you run out of unvisited neighbors, reset count to zero and try walking from the startpoint (to explore the opposite direction).
Of course this can work in any programming language. Try to implement this in MATLAB and if you get stuck you can consider to ask a more specific question.

Related

Object not rotating properly in unity? [closed]

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 2 years ago.
Improve this question
I can't really explane whats going on so here is the video:
I can't explain this
Something went wrong with the rotation axis? I don't know what cause it. I don't know how to fix it.
Its like someone messed something with the axis? I even don't know how to do that...
Please help me!
Don't worry, it's because you modify the value in Transform, in fact, the changed localPosition and localRotation are relative coordinate values; when this parameter is changed, it is relative to the parent node.
The objects we see in Scene are Position and Rotation, which are the values ​​in world coordinates, which are the relative coordinates plus the parent node's value in world coordinates.
So all you need to do is reset the Transform of the GameObject's parent node to the initial value.
then the modification of the relative coordinates will be consistent with the world coordinates.

Cartesian coordinates to LatLng in LeafletJS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
I am getting x,y (cartesian) coordinates for a map from an API. I "draw" this map using polylines, it looks like this:
Problem is: due to the projection, the hallways in the south are a lot wider than in reality. I tried converting the coordinates to LatLng with LayerPointToLatLng, but no luck. How do I properly convert cartesian coordinates to LatLng so that the distortion is compensated? Thank you!

NetLogo - Checkers(Draughts) [closed]

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
This year I need to finish my bachelor theses, and my task is to create a game known as checkers(or draughts). It wouldn't be a problem, but I have to write it in NetLogo using the Mutli-agent approach. So I cant use those well-known algorithms as Min-max or alfa-beta pruning. As I said, I have to use the Multi-agent approach, because in NetLogo every single piece is an agent, and they can communicate with each other. So as my teacher said me, I have to create a completely new algorithm. Could someone give me any advice or suggestion how to start, or describe it how it should work?
You can get ideas from this model and get started to develop your own:
CHECKERS by ALBERT LEE MCS1 PD. 5
This is the board game checkers. It follows the same rules as regular checkers, but without double-jumps, or triple-jumps, etc. The goal of the game is to jump every single of your opponent's pieces. Jumping pieces is done by jumping diagonally, over an opponent's piece. Only one color of the board is used for moving. Players take turns moving. On a regular move, when you don't want to jump an opponents piece, movement of one diagonal space is allowed. A red piece can only move in the direction toward the black pieces when the board is set up, and the black pieces do likewise. However, when either player's pieces get to the other end of the board, they become a king, known as "kinging," and either color king can move both forwards and backwards. The same one diagonal space rule applies, unless the king jumps, which it can jump also either forwards or backwards.
In my program, there are two steps to moving. First, you select the piece with your mouse. Then, you select the patch that you want to move the piece to. If you select a piece and select another piece instead of the patch, instead of moving the initially selected piece to that new piece, the new piece becomes selected, and the same rule of moving applies. To jump a piece, select the piece you want to jump with, and if the piece you want to jump is "jumpable," which means that the piece you want to jump with is one space diagonally with the piece you want to jump, and the next patch in that direction has no pieces. After selecting the piece you want to jump with, select that patch with no pieces. The "jumped" piece leaves the board.

Forever moving ball [closed]

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
How do I create a body [A ball Body] that will bounce around the screen, never losing or gaining speed, regardless of what it hits in cocos2d-box2d?
Set restitution of the fixture to 1, and friction to 0.
Box2D manual says:
Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1. Consider dropping a ball on a table. <...> A value of one means the ball's velocity will be exactly reflected. This is called a perfectly elastic collision.
A friction value of 0 turns off friction
Without friction and with perfectly elastic collision your ball will bounce around the screen, never losing or gaining speed in a static environment. If environment is not static, then colliding with moving object will change speed of the ball.
To solve this problem, I suggest next trick. Set contact listener, and in PostSolve method correct speed of you ball like this:
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{
if(contact->GetFixtureA()->GetBody() == YOUR_BALL_BODY ||
contact->GetFixtureB()->GetBody() == YOUR_BALL_BODY)
{
float speed = YOUR_BALL_BODY->GetLinearVelocity().Length();
float koef = YOUR_NEEDED_SPEED / speed;
YOUR_BALL_BODY->SetLinearVelocity(koef * YOUR_BALL_BODY->GetLinearVelocity());
}
}
How to set contact listener see there.
Periodically multiply the velocity of the body by the scalar quantity t/v.length where t is target velocity.
The other answer is likely a bit more complex than what you need.

How route can be drawn in iphone? [closed]

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 3 years ago.
Improve this question
Suppose I have array of points.I want to draw the route of that points in iphone. How it can be done. i dont get the appropriate answer till now . plz help me.
Assuming you have an array of CLLocationCoordinate2D called coords:
int size = sizeof(coords[0]) / sizeof(coords);
MKPolyline* line = [MKPolyline polylineWithCoordinates:coords count:size];
[mapView addOverlay:line];
Now i use Quartz to draw the path between that points.I take two points and draw line between that points and so on till the end of the array and it gives the route between starting point and end point.