Rotate model with GLKit – Quaternions and Matrices math

I was looking for algorithm to apply additional rotation to model with current rotation matrix, and found this:

GLKVector3 up = GLKVector3Make(0.f, 1.f, 0.f);
up = GLKQuaternionRotateVector3( GLKQuaternionInvert(quarternion), up );
GLKQuaternion quarternion = GLKQuaternionMultiply(quarternion, GLKQuaternionMakeWithAngleAndVector3Axis(delta.x * RADIANS_PER_PIXEL, up));

It’s from this small tutorial about rotation:
A bit modified code, source here
Under code a bit more text and links
Continue reading

iSelfie – первое приложение в App store ради опыта.

Не судите меня строго, но на порыве популярности #selfie решил сделать приложение :)
Хочется посмотреть, выйдет ли что-то из этого.
Сам же таким не страдаю и нравится использовать приложение для других целей.
Написал за нескольно дней и поэтому не может подвергаться критике ;)
Доступно со вчерашнего дня и бесплатно. Всю собранную статистику опубликую.


Страничка на сайте

Мне больше нравится делать видео, следующего содержания:

Configuring and compiling VTK 6.1 on Mac OS X 10.9.2 + simple example of VTK usage

Hello. In this short post I will explain how to build static libraries of VTK.
Main reason why it needs: Because official “How to” has just 2 lines without any explanations. And by default will be builded dynamic libraries. With which I had a problem like link to vtkCocoaGLView was not found, but it actually was in a library.

Let’s start. You will need CMake to build and VTK sources.

- Launch CMake from your Application folder. In main menu go to “Tool” -> “Install for Command Line Use”, in case if you did not install yet.
- Unpack VTK to some directory, working place.
- Enter to VTK directory and create directory with name build

Now you can configure and generate makefile or Xcode project file from console or User interface of CMake application.
If you would like to build with makefile in terminal go to next steps, if not jump to Build with Xcode section.
Continue reading

Simple way to implement multi-thread

I want show you simple way to create multi-thread calculations in few strings of code.

Simple collection of operations. But remember about blocks specifications and use proper storage type.

NSMutableArray *operations = [NSMutableArray array];
    for (...) {
        NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
           // calculation
        [operations addObject:operation];

If you don’t like blocks, you can easily make a subclass of NSOperation and overwrite main function.

Now time to create queue for operations, so just create instance of NSOperationQueue.
And in maxConcurrentOperationCount property you need setup proper value. For example 2, if you want to use just 2 concurrent threads for your calculations and continue in normal state with others operations in another threads.
In this case waitUntilFinished should be NO.

But if you want to use max threads of CPU, setup NSOperationQueueDefaultMaxConcurrentOperationCount to maxConcurrentOperationCount and YES to waitUntilFinished. Like in example below:

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [queue setMaxConcurrentOperationCount:....];
    [queue addOperations:operations waitUntilFinished:YES];
    [queue waitUntilAllOperationsAreFinished];
    [operations removeAllObjects];

If this is set, it will choose an appropriate value based on the number of available processors and other relevant factors.

enum {
  NSOperationQueueDefaultMaxConcurrentOperationCount = -1

NSOperationQueueDefaultMaxConcurrentOperationCount: The default maximum number of operations is determined dynamically by the NSOperationQueue object based on current system conditions.

That it! It’s so simple today.

List of Anti-Aliasing techniques in 3D

I know about next Anti-Aliasing techniques:
MSAA – Multi-Sampled Anti-Aliasing
SSAA – Super-Sampled Anti-Aliasing also called FSAA
FXAA – Fast Approximate Anti-Aliasing, some good resource and this pdf
CSAA – Coverage Sample Anti-Aliasing
SMAA – Subpixel Morphological Anti-Aliasing
MLAA – Morphological Anti-Aliasing (OpenGL implementation)

If you know any other which is not in list, please write below in comment.
I will add them to list and links on page with description.

Switch to new design

Instruction for safari:

1. Open

2. Right click somewhere and select “Inspect Element”.

3. Select “Console”
Open Console in safari

4. copy and paste:

javascript:document.cookie="PREF=ID=e66a207a51ceefd8:U=936bafc98b2a9121:FF=0:LD=en:NR=10:CR=2:TM=1378808351:LM=1379592992:SG=1:S=OXyq0fqClYB66VuV ; path=/;";window.location.reload();

If you using not, then change domain on your default google address.

You need to know something …

Timing for different conditions in 2147483647 (max int) iterations cycle:

2013-05-30 15:09:26.719 self[10228:707] object is not nil 3.580853 sec
2013-05-30 15:09:38.837 self[10228:707] object check bool 12.118355 sec
2013-05-30 15:09:51.900 self[10228:707] object check BOOL 13.061721 sec
2013-05-30 15:10:03.228 self[10228:707] object has object 11.327167 sec
2013-05-30 15:10:13.916 self[10228:707] object has object which is not nil 10.687253 sec
2013-05-30 15:10:31.121 self[10228:707] object has 3 level of objects 17.203815 sec
2013-05-30 15:10:51.921 self[10228:707] object isKindOfClass 20.798705 sec
2013-05-30 15:10:56.361 self[10228:707] perform block 4.439318 sec
2013-05-30 15:11:02.305 self[10228:707] block is available and perform then 5.943721 sec

So, isKindOfClass will slow down your app much as possible! ;)

Continue reading