GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_normal_octahedron_canonicalized_transform_base.h
Go to the documentation of this file.
1// Copyright 2016 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_
17
18#include <cmath>
19
24#include "draco/core/macros.h"
25#include "draco/core/vector_d.h"
26
27namespace draco {
28
29// Base class containing shared functionality used by both encoding and decoding
30// canonicalized normal octahedron prediction scheme transforms. See the
31// encoding transform for more details about the method.
32template <typename DataTypeT>
35 public:
38 typedef DataTypeT DataType;
39
41 // We expect the mod value to be of the form 2^b-1.
45
49
50 int32_t GetRotationCount(Point2 pred) const {
51 const DataType sign_x = pred[0];
52 const DataType sign_y = pred[1];
53
54 int32_t rotation_count = 0;
55 if (sign_x == 0) {
56 if (sign_y == 0) {
57 rotation_count = 0;
58 } else if (sign_y > 0) {
59 rotation_count = 3;
60 } else {
61 rotation_count = 1;
62 }
63 } else if (sign_x > 0) {
64 if (sign_y >= 0) {
65 rotation_count = 2;
66 } else {
67 rotation_count = 1;
68 }
69 } else {
70 if (sign_y <= 0) {
71 rotation_count = 0;
72 } else {
73 rotation_count = 3;
74 }
75 }
76 return rotation_count;
77 }
78
79 Point2 RotatePoint(Point2 p, int32_t rotation_count) const {
80 switch (rotation_count) {
81 case 1:
82 return Point2(p[1], -p[0]);
83 case 2:
84 return Point2(-p[0], -p[1]);
85 case 3:
86 return Point2(-p[1], p[0]);
87 default:
88 return p;
89 }
90 }
91
92 bool IsInBottomLeft(const Point2 &p) const {
93 if (p[0] == 0 && p[1] == 0) {
94 return true;
95 }
96 return (p[0] < 0 && p[1] <= 0);
97 }
98};
99
100} // namespace draco
101
102#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_
PredictionSchemeNormalOctahedronCanonicalizedTransformBase()
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:40
Point2 RotatePoint(Point2 p, int32_t rotation_count) const
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:79
VectorD< DataTypeT, 2 > Point2
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:37
PredictionSchemeNormalOctahedronCanonicalizedTransformBase(DataType mod_value)
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:42
int32_t GetRotationCount(Point2 pred) const
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:50
DataTypeT DataType
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:38
static constexpr PredictionSchemeTransformType GetType()
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:46
bool IsInBottomLeft(const Point2 &p) const
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:92
PredictionSchemeNormalOctahedronTransformBase< DataTypeT > Base
Definition prediction_scheme_normal_octahedron_canonicalized_transform_base.h:36
PredictionSchemeNormalOctahedronTransformBase()
Definition prediction_scheme_normal_octahedron_transform_base.h:37
Definition vector_d.h:30
Definition attribute_octahedron_transform.cc:21
PredictionSchemeTransformType
Definition compression_shared.h:96
@ PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON_CANONICALIZED
Definition compression_shared.h:108