c#中如何产生如何用cad画正弦曲线线

&>&绝对可以实现的 c# 绘制正弦函数
绝对可以实现的 c# 绘制正弦函数
上传大小:6KB
绝对可以实现的 c# 绘制正弦函数
Bitmap bitM = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
Graphics g = Graphics.FromImage(bitM);
g.Clear(Color.White);
const int size = 300;
double[] x = new double[size];
Pen pen = new Pen(Color.Teal);
//画正弦曲线的横轴间距参数。建议所用的值应该是 正数且是2的倍数。
//在这里采用2。
int val = 2;
float temp = 0.0f;
//把画布下移100。为什么要这样做,只要你把这一句给注释掉,运行一下代码,
//你就会明白是为
g.TranslateTransform(0, 100);
for (int i =200; i & i++)
//改变32,实现正弦曲线宽度的变化。
//改100,实现正弦曲线高度的变化。
x[i] = Math.Sin(2 * Math.PI * i / 64) * 100;
...展开收缩
综合评分:4
下载个数:
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有9条
画出正选函数图了
不知道用什么打开。。。楼主看到后给个回复吧。。
我也表示VS2012,VS2010打不开的说~~~真可惜
综合评分:
积分/C币:3
VIP会员动态
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
绝对可以实现的 c# 绘制正弦函数
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
举报的资源分:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*详细原因:
绝对可以实现的 c# 绘制正弦函数如何用C#2010实现画正弦曲线_百度知道
如何用C#2010实现画正弦曲线
我尝试过用GDI+画,但是不大熟悉GDI+所以代码该放在哪个事件里都不清楚....求各位大神解答
我有更好的答案
用mschart控件
什么玩意..求解释
你百一下,看看,应该是你想找的。当然 用GDI+应该也可以,mschart专门提供做报表的。
采纳率:29%
我做个这个,只不过是做成正弦曲线的样子罢了,不是真正的正弦曲线。用到得是DrawCurve函数的一个点的数组为参数的重载。
本回答被网友采纳
一个点一个点画吧
当然是一个点一个点的画啊...但是那个For循环应该放在窗体的Paint事件里还是Load事件里啊求解释
Load里面吧,最好用一个image来存画好的东西,要不然可能会画了然后被擦掉了
跪求完整代码
为您推荐:
其他类似问题
正弦曲线的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。C#画正弦曲线程序_百度文库
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C#画正弦曲线程序
&&C# 1. 编写在图片框中绘制直角坐标系和一条正弦曲线程序
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢如何绘制几何图形
绘制sin曲线
绘制2D坐标系
有图有代码
C#WPF 如何绘制几何图形? 怎么绘制坐标系?绘制sin曲线(正弦曲线)?
这离不开Path(System.Windows.Shapes)和StreamGeometry(System.Windows.Media)类。
完成该工程,我们首先要建立并绘制一个坐标系,然后在该坐标系中绘制sin曲线的点(x,y),最后,把曲线的点转换为屏幕坐标并连接;这样坐标系和sin曲线就绘制完成了。
代码下载:
如果有帮助,别忘了给评价!
一、建立WPF工程
二、添加代码
MainWindow.xaml 中代码
&Window x:Class="WPFDrawingTraning.MainWindow"
xmlns="&a target=_blank href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&http://schemas.microsoft.com/winfx/2006/xaml/presentation&/a&"
xmlns:x="&a target=_blank href="http://schemas.microsoft.com/winfx/2006/xaml"&http://schemas.microsoft.com/winfx/2006/xaml&/a&"
Title="MainWindow" Height="350" Width="525"&
&Canvas Name="mainPanel" HorizontalAlignment="Left" Height="320" VerticalAlignment="Top" Width="517"/&
MainWindow.xaml.cs中代码
using System.Collections.G
using System.L
using System.T
using System.Threading.T
using System.W
using System.Windows.C
using System.Windows.D
using System.Windows.D
using System.Windows.I
using System.Windows.M
using System.Windows.Media.I
using System.Windows.N
using System.Windows.S
namespace WPFDrawingTraning
/// &summary&
/// MainWindow.xaml 的交互逻辑
/// &/summary&
public partial class MainWindow : System.Windows.Window
//Canvas mainPanel = new Canvas();
public MainWindow()
InitializeComponent();
Drawsin();//绘制2D坐标系和sin曲线
Drawpentagon();
/// &summary&
/// 绘制一组线段
/// &/summary&
protected void Drawing()
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 50);
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = new Point(200, 70);
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentC
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureC
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
myPath.Data = myPathG
// Add path shape to the UI.
StackPanel mainPanel = new StackPanel();
mainPanel.Children.Add(myPath);
this.Content = mainP
/// &summary&
/// 绘制线段
/// &/summary&
protected void DrawingLine(Point startPt,Point endPt)
LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = startPt;
myLineGeometry.EndPoint = endPt;
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
myPath.Data = myLineG
mainPanel.Children.Add(myPath);
/// &summary&
/// 绘制星状线
/// &/summary&
protected void DrawingAstroid(Point center,double r)
double h1 = r * Math.Sin(18 * Math.PI / 180);
double h2 = r * Math.Cos(18*Math.PI/180);
double h3 = r * Math.Sin(36 * Math.PI / 180);
double h4 = r * Math.Cos(36 * Math.PI / 180); ;
Point p1 = new Point(r, 0);
Point p2 = new Point(r - h2, r - h1);
Point p3 = new Point(r - h3, r + h4);
Point p4 = new Point(r + h3, p3.Y);
Point p5 = new Point(r + h2, p2.Y);
Point[] values = new Point[] { p1, p2, p3, p4, p5 };
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
PathGeometry myPathGeometry = new PathGeometry();
for (int i = 0; i & values.L i++)
//DrawingLine(center, values[i]);
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint =
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = values[i];
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentC
myPathFigureCollection.Add(myPathFigure);
myPathGeometry.Figures = myPathFigureC
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
myPath.Data = myPathG
mainPanel.Children.Add(myPath);
/// &summary&
/// 绘制坐标系和sin曲线
/// &/summary&
private void Drawpentagon()
Point center = new Point(50, 50);
double r = 50;
DrawingAstroid(center, r);
double h1 = r * Math.Sin(18 * Math.PI / 180);
double h2 = r * Math.Cos(18 * Math.PI / 180);
double h3 = r * Math.Sin(36 * Math.PI / 180);
double h4 = r * Math.Cos(36 * Math.PI / 180); ;
Point p1 = new Point(r, 0);
Point p2 = new Point(r - h2, r - h1);
Point p3 = new Point(r - h3, r + h4);
Point p4 = new Point(r + h3, p3.Y);
Point p5 = new Point(r + h2, p2.Y);
Point[] values = new Point[] { p1, p3, p5, p2, p4 };
// Create a path to draw a geometry with.
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
StreamGeometry theGeometry = BuildRegularPolygon(values, true, false);
// Create a StreamGeometry to use to specify myPath.
theGeometry.FillRule = FillRule.EvenO
// Freeze the geometry (make it unmodifiable)
// for additional performance benefits.
theGeometry.Freeze();
// Use the StreamGeometry returned by the BuildRegularPolygon to
// specify the shape of the path.
myPath.Data = theG
// Add path shape to the UI.
mainPanel.Children.Add(myPath);
/// &summary&
/// 绘制连续的线段
/// &/summary&
/// &param name="values"&&/param&
/// &returns&&/returns&
private StreamGeometry BuildRegularPolygon(Point[] values, bool isClosed,bool isfilled)
// c is the center, r is the radius,
// numSides the number of sides, offsetDegree the offset in Degrees.
// Do not add the last point.
StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext ctx = geometry.Open())
ctx.BeginFigure(values[0], isfilled /* is filled */, isClosed /* is closed */);
for (int i = 1; i & values.L i++)
ctx.LineTo(values[i], true /* is stroked */, false /* is smooth join */);
/// &summary&
/// 绘制五角星
/// &/summary&
private void Drawsin()
Point point = new Point(this.mainPanel.Width, this.mainPanel.Height);
Point xypoint = new Point(point.X / 2, point.Y / 2);//新坐标原点
//x轴坐标起点
Point xstartpoint = new Point(0, point.Y / 2);
//x轴坐标终点
Point xendpoint = new Point(point.X, point.Y / 2);
//y轴坐标起点
Point ystartpoint = new Point(point.X / 2, point.Y);
//y轴坐标终点
Point yendpoint = new Point(point.X / 2, 0);
Line xline = new Line();
xline.Stroke = System.Windows.Media.Brushes.LightSteelB
xline.X1 = 0;
xline.Y1 = this.mainPanel.Height / 2;
xline.X2 = this.mainPanel.W
xline.Y2 = this.mainPanel.Height / 2;
this.mainPanel.Children.Add(xline);
Line yline = new Line();
yline.Stroke = System.Windows.Media.Brushes.LightSteelB
yline.X1 = this.mainPanel.Width / 2;
yline.Y1 = this.mainPanel.H
yline.X2 = this.mainPanel.Width / 2;
yline.Y2 = 0;
this.mainPanel.Children.Add(yline);
Point[] points=new Point[1000];
//绘制sin曲线,从原点(0,0)开始
Point zpoint = new Point(0, 0);
zpoint = XYTransf(zpoint, xypoint);
points[0] =//sin曲线的起点
for (int i = 1; i & 1000; i++)
//计算sin(x,y)
point.X =10 *//x
point.Y =10 * Math.Sin(i);//y
//坐标转换
point = XYTransf(point, xypoint);
points[i] =
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
StreamGeometry theGeometry = BuildRegularPolygon(points, true, false);
// Create a StreamGeometry to use to specify myPath.
theGeometry.FillRule = FillRule.EvenO
// Freeze the geometry (make it unmodifiable)
// for additional performance benefits.
theGeometry.Freeze();
// Use the StreamGeometry returned by the BuildRegularPolygon to
// specify the shape of the path.
myPath.Data = theG
// Add path shape to the UI.
mainPanel.Children.Add(myPath);
//构建的XY坐标系中的坐标转换为界面坐标系
public Point XYTransf(Point point, Point xypoint)
point.X += xypoint.X;
point.Y = xypoint.Y - point.Y;
//显示屏幕坐标系的位置
三、页面效果
private void Drawsin()
函数中完成:坐标系绘制,sin曲线绘制;
point是绘图坐标系中的点,xypoint(maincanvas.Width/2,maincanvas.Height/2)是绘图屏幕坐标的几何中心点( 图 坐标点转换,中x轴和y轴原点)的坐标。
public Point XYTransf(Point point, Point xypoint)函数返回值是在屏幕坐标绘制点的坐标。
//转换为界面坐标系
public Point XYTransf(Point point, Point xypoint)
point.X += xypoint.X;
point.Y = xypoint.Y - point.Y;
//显示屏幕坐标系的位置
1.mainPanel
是一个Canvas面板,我们在该面板绘制图形。
2.绘制坐标系,以mainPanel 的图形中心为坐标原点;
图 坐标点转换
3.计算sin(x,y)并转换为屏幕坐标点,取1000个坐标点,并存在points数组中
for (int i = 1; i & 1000; i++)
//计算sin(x,y)
point.X =10 *//sin x
point.Y =10 * Math.Sin(i);//sin y
//坐标转换
point = XYTransf(point, xypoint);
points[i] =
4.连接1000个sin(x,y)的屏幕坐标点,并显示在Canvas中
StreamGeometry theGeometry = BuildRegularPolygon(points, true, false);
通过该函数连接points中所有的点;
Path myPath = new Path();
myPath.Stroke = Brushes.B
myPath.StrokeThickness = 1;
StreamGeometry theGeometry = BuildRegularPolygon(points, true, false);
// Create a StreamGeometry to use to specify myPath.
theGeometry.FillRule = FillRule.EvenO
// Freeze the geometry (make it unmodifiable)
// for additional performance benefits.
theGeometry.Freeze();
// Use the StreamGeometry returned by the BuildRegularPolygon to
// specify the shape of the path.
myPath.Data = theG
// Add path shape to the UI.
mainPanel.Children.Add(myPath);
5.执行显示效果
点击“启动”或按键盘“F5”执行工程,显示界面。
看过本文的人也看了:
我要留言技术领域:
取消收藏确定要取消收藏吗?
删除图谱提示你保存在该图谱下的知识内容也会被删除,建议你先将内容移到其他图谱中。你确定要删除知识图谱及其内容吗?
删除节点提示无法删除该知识节点,因该节点下仍保存有相关知识内容!
删除节点提示你确定要删除该知识节点吗?没有更多推荐了,
不良信息举报
举报内容:
如何绘制几何图形
绘制sin曲线
绘制2D坐标系
有图有代码
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!

我要回帖

更多关于 hfss如何画正弦曲线 的文章

 

随机推荐