~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to ext/native/math/lin/plane.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _PLANE_H
 
2
#define _PLANE_H
 
3
 
 
4
#include "math/lin/vec3.h"
 
5
 
 
6
class Matrix4x4;
 
7
 
 
8
class Plane {
 
9
public:
 
10
        float x, y, z, d;
 
11
        Plane() {}
 
12
        Plane(float x_, float y_, float z_, float d_)
 
13
                        : x(x_), y(y_), z(z_), d(d_) { }
 
14
        ~Plane() {}
 
15
 
 
16
        float Distance(const Vec3 &v) const {
 
17
                return x * v.x + y * v.y + z * v.z + d;
 
18
        }
 
19
 
 
20
        float Distance(float px, float py, float pz) const {
 
21
                return x * px + y * py + z * pz + d;
 
22
        }
 
23
 
 
24
        void Normalize() {
 
25
                float inv_length = sqrtf(x * x + y * y + z * z);
 
26
                x *= inv_length;
 
27
                y *= inv_length;
 
28
                z *= inv_length;
 
29
                d *= inv_length;
 
30
        }
 
31
 
 
32
        // Matrix is the inverse transpose of the wanted transform.
 
33
        // out cannot be equal to this.
 
34
        void TransformByIT(const Matrix4x4 &matrix, Plane *out);
 
35
};
 
36
 
 
37
#endif