Creating an MKPolygon from the intersection of 2 or more MKPolygon objects - objective-c

Does anyone know if this is possible. I'm trying to create a pretty complex polygon, and was wondering if there's any way to take 2 or more objects that are MKPolygon's and create a new MKPolygon from it.
Thanks!

MKPolygon and it's ancestors are pretty simplistic. About the most you can do with ease is to make a large mkpolygon and start filling in inner polygon "holes" or rings to create more complex shapes.
That being said, if you're talking about real geometric math, unions, intersections, and more complex functions, you may want to use a geo-specific framework (or treat your lat/long as x/y double floats and just use regular textbook geometry functions to build 2d polys)
Michael Weisman has a good geo/GIS lib called ShapeKit, geared towards iOS specifically. It acts as a front end to GEOS and PROJ.4, two extremely powerful libraries. This is probably your best, safest bet.
Another option that you may want to explore, if you don't have to compute the polygons on the device, ... Serve up your polygons from a GIS powered database server. I have a few modifications to shapekit that let you import binary WKB polygons from mysql or elsewhere ... You've got fast powerful functions there to offload processing power if needed. Or you could even bring them straight from a Esri shapefile to iOS if that's where your coming from... I did a proof of concept of that on GitHub too.

I have written a solution for this. Check out MKPolygon-GPC. Its an Objective-C wrapper around Alan's the GPC lib.

Related

Reactive Extensions for .NET Developers

I found some information about this but I have several confusion regarding this. So when we need to use this RX.NET.
What are the important of using this items? When I need to use this?
As with every toolset, it can shape how you approach problems. Given a hammer, all your problems may become nails. It is the same with Rx.NET. It gives you a new approach. Whether you choose to use this approach for a particular problem is up to you, and as with any tool or technology, there are plusses and minuses. You will need to study and gain experience to make those sort of complex judgements for yourself.
For starters, Rx.NET allows you to cultivate the approach of programming 'reactively.' This is akin to functional programming, in the sense that you declare behavour as being composed of underlying behavior. Rx.NET allows you to specify functions over streams to give new streams. This powerful technique can be applied to almost any problem you can imagine.
For example, a program using Linq and Rx.NET to draw mouse movements as points on a screen within a bounding box would like something like:
mouseMovements.Where(box.Contains(m)).Subscribe(DrawPoint)
where mouseMovements would be your mouse event as an observable
You could declare the
myPointsInBox = mouseMovements.Where(box.Contains(m))
as its own observable and have multiple subscribers:
myPointsInBox.Subscribe(DrawPoint)
myPointsInBox.Subscribe(ConnectWithLines)
myPointsInBox.Subscribe(UpdatePointCounter)
you can make streams from streams
var everyThousandthPoint= myPointsInBox.Buffer(….).Select(…)
and then do things with them
everyThousandthPoint.Subscribe(FlashPointCounter)
You get the idea.

Creating a 3D Character Model with Procedural Generation

I'm slowly introducing myself into some procedural generation techniques. However, instead of generating a map or level in a video game, I want to learn how to create procedural character models.
I guess something that would be akin to this would be the creatures from the video game "Spore". The basic idea is that the program will choose from a set of pieces of a creature, and piece them together to create one model.
Where can I go to learn more about this?
Also, do you know of any game engines that may have some compatibility for this sort of project?
I think as long as the parts of your creature are static assets and predefined by you (together with the information where the joints and fixpoints are), it does not really matter which engine you use. All common engines like Unreal or Unity allow you to create a character in the game from different components, which would be your creature parts.
The only challenge I see is the problem of animating the creature. You will still need some kind of skeleton that tells the engine how to map the animation to your creature. Maybe you can have different creature trunks with skeletons and animation and fixpoints to attach your various parts like arms or legs.

What are the bad side effects of using singleton in my game engine design

Yes, I admit this is the same old question, but I used to apply this pattern heavily in my game engine (if it counts one) design.
I noticed in this question http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons , Jim Burger has given his answer, yes it's true that my codes are tightly coupled, but where I apply singletons are managers used in my engine, for instance, resource manager which manages all sorts of images, audios and data. I can ask for resource anywhere in my code "ResourceManager.getInstance().getImageAndCacheIt("someimage"); ", so on top of my engine, the game logic codes are coupled tightly with it.
It is common your codes? Is there a better solution?
And I used to think that some of the Classes which Android Activity uses are singletons, however after digging into the source code, I found that they are surprisingly not, they are lazily instantiated with some configuration, should I use this approach instead?
And would you be so kind as to tell me some of your engine design experiences, what subsystems do I need, do you use a visual tree or draw your elements directly line by line?
By the way, what language do you use to make 3d video games, java or c++ or something else, now I'm working on java/opengl es
A common alternative to singletons is to use Dependency Injection.

Is there any coding involved when making a game with something like blender or UDK?

With these programs, it seems like every aspect of the game is done through the GUI. Is there any coding when making games through these programs? Like would you code in collision detection, or would that be done through the GUI?
I don't know the Unreal engine but Unity3D and SIO2 but the situation should be similar. Basically a lot of programming is taken from you and can be done through setting properties like in a Blender material. But at the end you have to do at least a little bit of coding.
The process of collision detection for example involves attaching a collider to your player character and another one to your obstacle. Then you have to attach a small script to your player like this.
void OnTriggerEnter (Collider collider) {
if (collider.material.name.Equals ("ObstaclePhysicMaterial")) {
player.PlayAnimation ("Die");
// your code snippet to game over or whatever
}
}
Not too abstract but it has to be done and of course your game over logic will include some more code to reset all objects to their initial position. So at the end you cannot avoid coding but when I started learning Blender I made the experience that more complex Blender scenes have indeed similarities to programming. You have to plan your scene and find the most efficient structure to avoid unnecessary work i.e. thinking in terms of logic is slightly analogue.
So if you plan a game with heavy graphics and not too sophisticated logic I like to encourage you to give scripting a try. Start with studying sample projects.
With development kits you usually get. The most important part the engine. Sometimes materials and land scape tools. All you do really is the scripting part. Events, environmental variables, usually in LUA or python. Not the actual engine and physics.... the hard part.

Open Source Objective-C Math/Calculator engine

Hej guys,
I was wondering if you know any well working Math or Calculation engines written in Objective-C? Found a graphing one using CorePlot already....
Thanks for your help! :)
You might get some use out of David Stes' CAKit (a computer algebra package), but you'll have a ton of hacking to do, since Stes is ravingly anti-FoundationKit and wrote the whole thing based on the old, pre-NeXT ICPak API. (Don't go looking to him for help -- you'll get a world of hurt.)
The key issue to keep in mind is that ICPak was based on Smalltalk and describes more or less the intended function of the class, while FoundationKit class names tend to describe the raw functionality itself; the most useful correlation will probably be OrdCltn -> NSMutableArray; you'll also have to tweak the memory management to use autorelease. It's not impossible, but you do have to understand the philosophy that FoundationKit follows.