circle.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "tango-gl/circle.h"
18 
19 namespace tango_gl {
20 Circle::Circle(float radius, int resolution) : Mesh(GL_TRIANGLE_FAN){
21  SetShader();
22  std::vector<GLfloat> vertices;
23  vertices.reserve(3 * (resolution + 2));
24  vertices.push_back(0);
25  vertices.push_back(0);
26  vertices.push_back(0);
27  float delta_theta = M_PI * 2.0f / static_cast<float>(resolution);
28  for (int i = resolution; i >= 0; i--) {
29  float theta = delta_theta * static_cast<float>(i);
30  vertices.push_back(cos(theta) * radius);
31  vertices.push_back(0);
32  vertices.push_back(sin(theta) * radius);
33  }
34  SetVertices(vertices);
35 }
36 } // namespace tango_gl
static const float vertices[]
Definition: quad.cpp:39
void SetShader()
Definition: mesh.cpp:28
GLM_FUNC_DECL genType cos(genType const &angle)
GLM_FUNC_DECL genType sin(genType const &angle)
Circle(float radius, int resolution)
Definition: circle.cpp:20
void SetVertices(const std::vector< GLfloat > &vertices)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:30