绘制一个球

根据公式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. Java中如何防止内存泄漏的发生

    在Java开发中我们常常会遇到内存泄漏的情况发生.那么为什么会发生内存泄漏,以及怎样去防止! 内存泄漏的定义:对象已经没有被应用程序使用,但是垃圾回收器没办法移除它们,因为还在被引用着. 为什么会发生 ...

  2. VSC 使用Git进行版本控制

    Visual Studio Code 使用Git进行版本控制 请确保你安装了最新的VS Code.http://code.visualstudio.com/ 请确保安装了最新版的Git.https:/ ...

  3. iOS VideoToolbox硬编H.265(HEVC)H.264(AVC):4 同步编码

    本文档描述Video Toolbox实现同步编码的办法. Video Toolbox在头文件描述了编码方式为异步,实际开发中也确实为异步. This function may be called as ...

  4. VS连接远程数据库,连接sqlserver2008,显示“基础提供程序在 Open 上失败”

    今天安装完成VS2012后,在调试2010的程序的时候,出现“基础提供程序在 Open 上失败”,于是用vs连接远程sql2008,才发现问题是:“已成功与服务器连接,但是登录前的握手期间发生错误”, ...

  5. Careercup - Facebook面试题 - 5733320654585856

    2014-05-02 09:59 题目链接 原题: Group Anagrams input = ["star, astr, car, rac, st"] output = [[& ...

  6. 【转】 Android经验: proguard 阻碍 webview 正常工作

    转自:http://blog.csdn.net/span76/article/details/9065941 WebView 常识 使用 Alert  提供消息 我在页面经常用 Alert 提供消息, ...

  7. Zabbix实现告警分级

    Zabbix中trigger的severity的值定义了trigger的不同严重程度,其中severity默认的6个值为 Not classified, Information, Warning, A ...

  8. iframe嵌入其他网站,如何自适应高度

    终于有一周时间,工作不那么忙了,腾出手来总结下工作过程中学到的知识. 每天遇到新问题,解决新问题,但是却很少有时间去仔细研究下,或者总结下.攒的多了,就得从头捋一遍. 说下iframe自适应高度: 搜 ...

  9. Linux 操作Mysql详解

    一.引言 想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL.本以为有 Windows下使用SQL Server的经验,觉得在Linu ...

  10. servlet中获取request中文乱码问题分析

    request.setCharacterEncoding("utf-8");//第一种情况 log.info("服务商名称:" + request.getPar ...