Gooey Effect in iOS [closed] - ios

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'm working on a little project in which I would like two circles to connect through a gooey effect. I've searched the web quiet a lot and came across some examples in the form of a tabbar, or sidebar menu, but that's all fixed and not what I'm looking for.
What I basically want is the following. So there is a circle and if I drag it closely to another circle it snaps together, also known as the gooey effect.
A code sample would be the best, but a direction / approach of how to do this will help me out as well.

Interesting problem.
Off the top of my head, here is how I might handle it:
Calculate the points of intersection of the 2 circles (I found this link for that: Circle-circle intersection points)
Calculate the arc ranges of the intersecting parts of each circle.
Widen those arc ranges by a few degrees. Define the arcs for the remaining parts of each circle (The parts that would be drawn "non-gooey")
Using trig and Catmull-Rom splines, create a closed path for the outer "non-gooey" parts of each circle.
The Catmull-Rom algorithm should fill in the gaps between the 2 part-circles using smooth curves that look a lot like the "Gooey" circles you show.
I have a project on github that includes Swift code for creating Catmull-Rom splines from a series of points: Trochoid demo
That project creates open curves, not closed paths. The technique for creating smoothed closed paths using Catmull-Rom Splines is a little different. I have another Github project called RandomBlobs (Written in Objective-C) that creates smoothed closed paths. You should be able to work out how to change the Swift code to create closed paths from the Objective-C code. It's been long enough since I wrote the RandomBlobs code that I don't remember exactly what I did.
I'm not sure if the approach I describe above would be fast enough to draw in real time, but I bet it would. That TrochoidDemo project is doing a lot of trig for each animation frame, and it's animation is pretty smooth. If your project isn't smooth enough you might need to do some optimization.

Related

How to detect users’ freehand drawing to primitive geometrical objects like square, circle, triangle [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 7 years ago.
Improve this question
I am currently looking for some guide/samples on how to implement the OS X Yosemite’s markup like features. i.e., auto detecting/guess freehand drawing to match users’ intention of whether they are trying to draw circle, square, or triangle.
Please refer the image below, the left side represents the users freehand drawing and the right is auto-detected shapes replaced by OS X markup.
Recognizing objects from gestures is a subject of ongoing research. There is a class of algorithms called "$ recognizers" that you might want to look at. The original algorithm is "The $1 Recognizer" which is worth a read.
It is not that difficult to implement such recognizers, as long as you are limited to a specific class of shapes. The $1 recognizer (if I recall correctly) only works for a continuous path (so "X" would not work because it requires two strokes). However, later work has extended the $1 recognizer for non-continuous cases.

Need some tips which localization method to use for my NAO robot (robotic) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
for university I'm working on a project in which I have to teach a robot(Nao-robot) play nine men's morris. Unfortunately I'm fairly new to the area of robotics and I need some tips how to solve some problems. Currently I'm working on the localization/orientation of the robot and I'm wondering which approach of localization would fit best in my project.
A short explanation of the project:
The robot has a fixed starting position and has to walk around on a boardwhich has a size of about 3x3 meter ( I will post a picture of the board when i reach 10 reputation). There are no obstacles on the field except the game tokens and the game lines are marked yellow on the board. For orientation I use the two camera devices the robot has.
I found some approaches like
Monte Carlo Localization
SLAM (Simultaneous Localization and Mapping)
but these approaches seem to be quite complex for a beginner like me and I would really appreciate if some has some good ideas what would be a simpler way to solve this problem. Functionality has for me a far higher priority than performance.
I have vague knowledge about the nine men's morris game as such, but I will try to give you my simpler idea.
First thing first, you need to have a map of your board. This should be easy in your case, cause your environment is static. There are few technique to do this mapping from your board. For your case I would suggest to have a metric map, which is an occupancy grid. Assign coordinates to each cell in the grid. This will be helpful in robot navigation.
As you have mentioned, your robot starts from a fixed position. On start up, initialize your robot with this reference location and orientation (with respect to X-Y axes of the grid, may be you don't need the cameras, I am not sure!!). By initialization I mean, mark your position on the grid.
Use Dead Reckoning for localization and keep updating position and orientation of your robot as it move through the board. I would hope that your robot get some feedback from the servos, like number of rotations and so forth. Do that math and update the position coordinates of your robot as it move into different cell in the grid.
You can use A-Star algorithm to find a path for your robot. You need to do the path planning before you want to navigate. You also have to mark those game tokens on the grid, to avoid collisions in planning the path.

How to create a randomly generated line using Swift in xCode [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
In the Image above (Top Image), suppose the black boundary is the phone.
What i was trying to achieve is to randomly generate the red path from the top of the screen and at the same time the red line (path) moves downwards.
Notice how the red path is random and does not have a uniform shape.
My question is how do i achieve this?
I know this has something to do with the random function.
But then generating the random path has been my main obstacle since 8 hours.
I could not generate a shape at every interval of the timer with a specific x coordinate and y coordinate but then as you can see in the next image, how would i generate the line at an angle (rotated)
Have tried hard to search everywhere on the internet but failed.
I always keep stackoverflow my last destination after I fail to achieve any functionality after numerous hours.
Would really appreciate if anyone could help me out with this.
It looks like you could achieve the effect you wish by starting at the top center, and repeatedly choosing 2 random numbers: how far down to go, and how far horizontally to go (positive or negative), until you got to the bottom of the screen. You'd have to be careful not to go off either edge, or you could instead choose a random x-coordinate each step.

Creating a words grid for a search word game [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to draw a words grid that user can select the wrods, like the image below
I think the best way is to use a UICollectionView element for draw a grid but how can I handle touch events and mark selected letters?
There is no one answer to your question. You could use individual UIButtons for each letter or set up your own touch coordinate tracking system corresponding to letters or do something completely different. It boils down to what you feel comfortable working with and your experience level. To get the ball rolling, I would suggest you take a look at this Ray Wenderlich tutorial which shows how to create a letter word game by dragging letter tiles. The tech in this tutorial will definitely help you with your project.
Updated:
If you go the button route, you can create them programmatically and pretty much do anything you want. Change their title (in your case) letter, show or hide them, track various kind of touches, and so on. For the letters and tracking touches, there are probably a number of methods of doing this. Try putting your letters on a subview while keeping track of their center coordinates. Then add a new subview over your letters to track the user's touches.
You will have to read and understand the UIGestureRecognizer Class.
Here is an example of how to get a user's screen coordinates from a touch.

iOS fastest way to draw many rectangles [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 9 years ago.
Improve this question
I want to display audio meters on the iPad consisting of many small green, red or black rectangles. They don't need to be fancy but there may be a lot of them. I am looking for the best technique to draw them quickly. Which of the following techniques is better: text atlas in CALayers or OpenGLES or another?
Thank you for your answers before the the question was closed for being too broad. Unfortunately I couldn't make the question narrow because I didn't know which technology to use. If I had known the answer I could have made the question very narrow.
The fastest drawing would be to use OpenGLES in a custom view.
An alternative method would be to use a texture atlas in CALayers. You could draw 9 sets of your boxes into a single image to start with (0-8 boxes on), and then create the 300 CALayers on screen all using that as their content. During each frame, you switch each layer to point at the part of the texture atlas it needs to use. I've never done this with 300 layers before, so I don't know if that may become a problem - I've only done it with a half dozen or so digits that were updating every frame, but that worked really well. See this blog post for more info:
http://supermegaultragroovy.com/2012/11/19/pragma-mark-calayer-texture-atlases/
The best way to draw something repeatedly is to avoid drawing it if it is already on the screen. Since audio meters tend to update frequently, but most of their area stay the same, because audio signals are relatively smooth, you should track what's drawn, and draw only the differences.
For example, if you have drawn a signal meter with fifty green squares in a previous update, and now you need to draw forty eight green squares, you should redraw only the two squares that are different from the previous update. This should save you a lot of quartz calls.
Postpone rendering to the point where it's absolutely necessary, i. e. assuming you're drawing with CoreGraphics, use paths, and only stroke/fill the path when you have added all the rectangles to it.

Resources