matrix_math
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Objective C example on how to make a 3D effect using matrix multiplication
== MatrixMath

This app is an example of how to produce a 3D effect using simple math.

== How does it work?

In the core of this example is the following function:

  - (void) transform:(NSArray *)pts yrt:(CGFloat)yrt zrt:(CGFloat)zrt {
    if (pts==nil) return;
    
    CGFloat c1, s1, c2, s2;
    
    c1 = (CGFloat) cos(zrt);
    s1 = (CGFloat) sin(zrt);
    c2 = (CGFloat) cos(yrt);
    s2 = (CGFloat) sin(yrt);
    
    for (Point3D *p in pts) {
        float x = p.x * c1 * c2 - p.y * s2 - p.z * c2 * s1;
        float y = p.x * c1 * s2 + p.y * c2 - p.z * s1 * s2;
        float z = p.x * s1      + 0        + p.z * c1;
        
        p.x = x; 
        p.y = y; 
        p.z = z; 
    }
  }

It accepts a list of 3D points, Y rotation delta and Z rotation delta. It then transforms all of the points based on the rotation deltas.
To display the points, use the x and z coordinates. 

== How to test this example?

Download the code and run it. Drag your finger on the screen and see what you get.





本源码包内暂不包含可直接显示的源代码文件,请下载源码包。