public void renderdata(Graphics g) { float scale_radius = 1.5f; Rectangle area = new Rectangle(0, 0, (int)g.VisibleClipBounds.Width, (int)g.VisibleClipBounds.Height - 5); g.Clear(Color.White); Pen radlines = new Pen(Color.FromArgb(0, 0, 0), 1.0f); //!Dibujar rango angular- lineas guia Point linea1 = new Point(); Point linea2 = new Point(); PointF center = new PointF(0.0f, -1.0f); PointF startvec = new PointF(scale_radius, -1.0f); //Obtener el rango angular if (angular_range == 100) { rotatePoint(center, 40.0f, ref startvec); } PointF vec = new PointF(startvec.X, startvec.Y); PointF oldvec = new PointF(); int ang; for (ang = 0; ang <= angular_range; ang += 10) { //dibujar linea transformMathCoordToGUICoord(center, ref linea1, area); transformMathCoordToGUICoord(vec, ref linea2, area); g.DrawLine(radlines, linea1, linea2); oldvec = new PointF(vec.X, vec.Y); rotatePoint(center, 10.0f, ref vec); } //Dibujar lineas concentricas float rango_distancia = 0; float interval_dis; if (distance_range == 8) { rango_distancia = 8 * scale_range; interval_dis = 1.0f / rango_distancia; } else { rango_distancia = 80 * scale_range; interval_dis = 4.0f / rango_distancia; } Pen gradepen = new Pen(Brushes.LightGray, 0.5f); if (rango_distancia <= 2.0f) { drawGridLines(g, gradepen, interval_dis * 0.02f, angular_range, startvec, center, area); } gradepen = new Pen(Color.FromArgb(120, 120, 120), 1.0f); drawGridLines(g, gradepen, interval_dis * 0.1f, angular_range, startvec, center, area); gradepen = new Pen(Color.FromArgb(100, 100, 100), 2.0f); drawGridLines(g, gradepen, interval_dis, angular_range, startvec, center, area); //Dibujar la grafica de datos if (laser_data != null) { gradepen = new Pen(Brushes.Green, 2.0f); float radius_len = 0; vec = new PointF(startvec.X, startvec.Y); oldvec = new PointF(); //obtener resolución angular float resolution = laser_data.get_resolution(); //obtener cantidad de datos uint distance_count = laser_data.get_distance_count(); for (ang = 0; ang < distance_count; ang++) { radius_len = laser_data.get_distance(ang);//obtener medida de distancia radius_len /= rango_distancia; PointF radiusvec = new PointF(radius_len * (vec.X - center.X), radius_len * (vec.Y - center.Y)); PointF radius_point = new PointF(radiusvec.X + center.X, radiusvec.Y + center.Y); if (ang > 0) { transformMathCoordToGUICoord(oldvec, ref linea1, area); transformMathCoordToGUICoord(radius_point, ref linea2, area); g.DrawLine(gradepen, linea1, linea2); } rotatePoint(center, resolution, ref vec); oldvec = new PointF(radius_point.X, radius_point.Y); } } //dibujar rotulo de distancia vec.X = 0.0f; vec.Y = -1.0f + scale_radius; transformMathCoordToGUICoord(vec, ref linea1, area); string rotulodis = rango_distancia.ToString() + "m"; Font ft = new Font("courier new", 10.0f); g.DrawString(rotulodis, ft, System.Drawing.Brushes.Black, (float)linea1.X, (float)linea1.Y - 15); }
private void export_to_model_linear(LaserDataSceneNode node) { float min_angle = m_current_laser_buffer.get_min_angle(); float ang_increment = m_current_laser_buffer.get_resolution() * m_mesh_resolution; uint num_h_samples = m_current_laser_buffer.get_distance_count(); uint horizontal_count = num_h_samples / m_mesh_resolution; float vertical_increment = m_vertical_scale * (m_vertical_sampler_max - m_vertical_sampler_min) / m_vertical_sampler_count; ushort sides = (ushort)horizontal_count; ushort slices = (ushort)m_vertical_sampler_count; // crear los vertices MeshBuffer mbuffer = node.get_mesh_buffer(); uint vert_count = (uint)(sides * slices); mbuffer.AllocateVertices(vert_count); m_buffer_index = 0; float vertical_value = m_vertical_sampler_min * m_vertical_scale; float angular_value = min_angle; for (ushort i = 0; i < slices; i++) { angular_value = min_angle; for (ushort j = 0; j < sides; j++) { float distance = m_laser_distances[num_h_samples * i + j * m_mesh_resolution]; Vector3D pivot = new Vector3D(); Vector3D normal = new Vector3D(); normal.Z = -(float)Math.Cos(deg_to_rad((double)angular_value)); normal.Y = -(float)Math.Sin(deg_to_rad((double)angular_value)); normal.X = 0; pivot.Z = normal.Z * distance; pivot.Y = normal.Y * distance; pivot.X = vertical_value; Vertex3D newvertex = new Vertex3D(); newvertex.Position = pivot; newvertex.Normal = normal; newvertex.Color = new Color(255, 0, 0, 150); newvertex.TCoords = new Vector2D(1, 1); mbuffer.SetVertex(m_buffer_index, newvertex); m_buffer_index++; angular_value += ang_increment; } vertical_value += vertical_increment; } create_model_indices(node, sides, slices); }