博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TeeChart显示三维的图形,使用Surface
阅读量:4618 次
发布时间:2019-06-09

本文共 3802 字,大约阅读时间需要 12 分钟。

绘制一个球

根据公式x^2+y^2+z^2=R^2;

令x=RsinAcosB  y=RcosAcosB z=RsinB

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using Steema.TeeChart;using Steema.TeeChart.Styles;using System.Drawing.Drawing2D;using Steema.TeeChart.Tools;namespace WindowsFormsApplication1{    public partial class Form1 : Form    {        private TChart tChart1 = new TChart();        private Surface surfaceSeries1 = new Surface();        private GridBand gridBand = new GridBand();        private Surface surfaceSeries2 = new Surface();        public Form1()        {            InitializeComponent();            Init();        }        private void Init()        {            tChart1.Series.Add(surfaceSeries1);            tChart1.Series.Add(surfaceSeries2);            tChart1.Dock = DockStyle.Fill;            this.tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;            this.tChart1.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;            this.tChart1.Axes.Depth.Visible = true;            this.tChart1.Axes.Depth.Labels.ValueFormat = "0.#";            this.tChart1.Axes.Depth.Increment = 0.2;            this.tChart1.Axes.Bottom.Labels.ValueFormat = "0.#";            this.tChart1.Axes.Bottom.Increment = 0.1;            this.tChart1.Aspect.Chart3DPercent = 100;            this.tChart1.Aspect.Orthogonal = false;            this.tChart1.Aspect.Perspective = 50;            this.tChart1.Aspect.Rotation = 327;            this.tChart1.Aspect.Elevation = 352;            this.tChart1.Aspect.Zoom = 70;            this.tChart1.Walls.Bottom.Pen.Visible = false;            this.tChart1.Walls.Bottom.Size = 5;            this.tChart1.Walls.Left.Pen.Visible = false;            this.tChart1.Walls.Left.Size = 5;            this.tChart1.Panel.Brush.Color = System.Drawing.Color.FromArgb(((System.Byte)(254)), ((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));            Controls.Add(tChart1);            InitSurface(surfaceSeries1, Color.Red);            InitSurface(surfaceSeries2, Color.Blue);            double r = 10;            double z = 0;            List
arrayX = new List
(); List
arrayY = new List
(); List
arrayZ = new List
(); List
arrayX1 = new List
(); List
arrayY1 = new List
(); List
arrayZ1 = new List
(); tChart1.AutoRepaint = false; try { for (double x = -r; x <= r; x += 0.1) { for (double y = -r; y <= r; y += 0.1) { z = r * r - x * x - y * y; if (z >= 0) { z = Math.Sqrt(z); arrayX.Add(x); arrayY.Add(y); arrayZ.Add(-z); } } } for (double x = -r; x <= r; x += 0.1) { for (double y = -r; y <= r; y += 0.1) { z = r * r - x * x - y * y; if (z >= 0) { z = Math.Sqrt(z); arrayX1.Add(x); arrayY1.Add(y); arrayZ1.Add(z); } } } surfaceSeries1.Add(arrayX.ToArray(), arrayZ.ToArray(), arrayY.ToArray());//特别需要注意的是,z在中间 surfaceSeries2.Add(arrayX1.ToArray(), arrayZ1.ToArray(), arrayY1.ToArray()); } catch (Exception ex) { MessageBox.Show(ex.Message); } tChart1.AutoRepaint = true; tChart1.Refresh(); } private void InitSurface(Surface s, Color color) { s.Pen.Color = color; s.Marks.Symbol.Shadow.Height = 1; s.Marks.Symbol.Shadow.Visible = true; s.Marks.Symbol.Shadow.Width = 1; s.NumXValues = 25; s.NumZValues = 25; s.PaletteMin = 0; s.PaletteStep = 0; s.UseColorRange = false; s.UsePalette = true; s.IrregularGrid = true; s.ShowInLegend = false; s.UseColorRange = false; s.UsePalette = true; s.PaletteStyle = Steema.TeeChart.Styles.PaletteStyles.Strong; s.PaletteSteps = 10; } }}

转载于:https://www.cnblogs.com/chucklu/p/4514005.html

你可能感兴趣的文章
PageControl的小点点随ScrollView滑动而变动代码
查看>>
(十三)在ASP.NET CORE中使用Options
查看>>
关于博主
查看>>
贝叶斯规则
查看>>
解决Centos/Redhat,命令不存在
查看>>
项目实战—小饭桌
查看>>
ArrayList深拷贝的一种实现方法
查看>>
2012考研英语--前辈的高分复习经验
查看>>
UVA10603倒水问题+隐式图搜索
查看>>
C++学习之字符串
查看>>
图像化列表
查看>>
2014年10月9日——语言基础2
查看>>
mysql查
查看>>
[正则表达式]难点和误区
查看>>
217. Contains Duplicate
查看>>
hadoop遇到问题总结
查看>>
Windows下手动安装redis服务
查看>>
把 MongoDB 当成是纯内存数据库来使用(Redis 风格)
查看>>
PyTorch 1.0 中文官方教程:使用ONNX将模型从PyTorch传输到Caffe2和移动端
查看>>
LeetCode 4Sum
查看>>