绘制一个球

根据公式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 = ;
this.tChart1.Aspect.Orthogonal = false;
this.tChart1.Aspect.Perspective = ;
this.tChart1.Aspect.Rotation = ;
this.tChart1.Aspect.Elevation = ;
this.tChart1.Aspect.Zoom = ; this.tChart1.Walls.Bottom.Pen.Visible = false;
this.tChart1.Walls.Bottom.Size = ; this.tChart1.Walls.Left.Pen.Visible = false;
this.tChart1.Walls.Left.Size = ;
this.tChart1.Panel.Brush.Color = System.Drawing.Color.FromArgb(((System.Byte)()), ((System.Byte)()), ((System.Byte)()), ((System.Byte)())); Controls.Add(tChart1); InitSurface(surfaceSeries1, Color.Red); InitSurface(surfaceSeries2, Color.Blue); double r = ;
double z = ; List<double> arrayX = new List<double>();
List<double> arrayY = new List<double>();
List<double> arrayZ = new List<double>(); List<double> arrayX1 = new List<double>();
List<double> arrayY1 = new List<double>();
List<double> arrayZ1 = new List<double>(); 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 >= )
{
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 >= )
{
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 = ;
s.Marks.Symbol.Shadow.Visible = true;
s.Marks.Symbol.Shadow.Width = ;
s.NumXValues = ;
s.NumZValues = ;
s.PaletteMin = ;
s.PaletteStep = ;
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 = ;
}
}
}

TeeChart显示三维的图形,使用Surface的更多相关文章

  1. Matlab——图形绘制——三维立体图形 剔透玲珑球 动态图——彗星状轨迹图

    三维绘图函数 三维绘制工具 函数view 实例:三维螺旋线 >> t=:pi/:*pi; plot3(sin(t),cos(t),t) grid %添加网格  plot3可以画出空间中的曲 ...

  2. VS2015编写的MFC上位机,波特率可调,可动态显示曲线,可显示三维

    VS2015编写的MFC上位机,波特率可调,可动态显示曲线,可显示三维 2016年01月14日 11:40:28 博博有个大大大的Dream 阅读数:9375   版权声明:本文为博主原创文章,未经博 ...

  3. 科学计算三维可视化---TVTK入门(创建和显示三维对象)

    一:创建一个基本的三维对象 (一)长方体操作 traits:就是TVTK对象的属性 (1)对象属性操作 >>> from tvtk.api import tvtk >>& ...

  4. Cocos2d 利用继承Draw方法制作可显示三维数据(宠物三维等)的三角形显示面板

    很久没有写博客了,这段时间比较忙,又是搬家又是做自己的项目,还有太多琐碎的事情缠身,好不容易抽出时间把最近自己做的一些简单例子记录一下. 在我的项目中,我需要一个显示面板来显示游戏中的一个三维数据,例 ...

  5. 使用Xming显示Oracle Linux图形界面

    如果你在尝试各种官方说明文档中的方法之后,xclock仍然无法远程显示. 系统 Win10 - Oracle Linux 7.5 Xming的文档以及网上教程都说的是Xming相关的配置 但是,要显示 ...

  6. [Swift]LeetCode892. 三维形体的表面积 | Surface Area of 3D Shapes

    On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cu ...

  7. VS+OpenGl 显示三维STL模型 代码

    今天调出了用VS环境结合OpenGL glut工具包进行显示STL模型的模块,进行了渲染.效果: 如下,后期会进行进一步优化,先贴上: #ifndef DATA_H #define DATA_H st ...

  8. autoCAD绘制简单三维立体图形

    第一步: 首先绘制一个简单的(封闭的)二维图形: 第二步: 变换观察视角,比如修改为 变换后的视角: 第三步: 选中闭合图形边框,使用组合键"ctrl + shift + E",然 ...

  9. origin显示三维曲面

    准备数据并选中数据: 这里如果只关心z<1部分的趋势,可以对Z轴范围进行调整,双击Z轴的数字: 然后修改显色条的范围,双击曲面: 最后让曲面最上面部分clip掉: 成功了:

随机推荐

  1. mac安装cocoapods

    sudo gem install cocoapods

  2. 升级Mac osx 10.10 后安装php 的mcrypt extension

    昨天折腾到凌晨四点多,今天又到这个点,终于成功了,心情比较复杂,先记录一下,改日再整理,此刻头昏脑胀,只想蒙头大睡. 发的问题,还没人回复,自己找到答案了,英语比较蹩脚,凑合看.. http://st ...

  3. npm,grunt,less,sass,typescript

    typescript   http://www.typescriptlang.org sass   http://sass-lang.com/ less http://lesscss.org/ bow ...

  4. C++中的运算符优先级

    1   ()  []  .  ->2   !  ~   -(负号) ++  --   &(取变量地址)*   (type)(强制类型)    sizeof 3   * / % 4   + ...

  5. android重写view和viewgroup的区别

    重写view: View类一般用于绘图操作,重写它的onDraw方法,但它不可以包含其他组件,没有addView(View view)方法. 重写viewgroup: ViewGroup是一个组件容器 ...

  6. Spring实现AOP的4种方式(转)

    转自:http://blog.csdn.net/udbnny/article/details/5870076 Spring实现AOP的4种方式 先了解AOP的相关术语:1.通知(Advice):通知定 ...

  7. WEB前端常用的测试工具

    一.QUnit 前端测试工具 QUnit是一个强大的JavaScript单元测试框架,该框架是由jQuery团队的成员所开发,并且是jQuery的官方测试套件.Qunit是Jquery的单元测试框架, ...

  8. spoj 274

    离散化   枚举行  扫描横坐标 #include <iostream> #include <cstdio> #include <cstring> #include ...

  9. linux配置mysql,tomcat命令vi

    [root@yangchehome bin]# ./mysqld_safe -user=mysql & [1] 17135 [root@yangchehome bin]# 140316 16: ...

  10. Apache Ignite——新一代数据库缓存系统

    [编者按]飞速增长的数据需要大量存储,对这些数据的管理也不是一件容易的事.但相比于存储和管理,如何处理数据才是开发人员真正的挑战.对于TB级别数据的存储和处理通常会让开发人员陷入速度.可扩展性和开销的 ...