以窗体形式绘制回旋曲线 [英] To draw clothoid curve in windows form

查看:77
本文介绍了以窗体形式绘制回旋曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在面板中绘制回旋曲线,但由于cos和sin函数,坐标值的范围从-1到1。任何人都可以告诉我如何变换面板大小,以便我可以绘制回旋曲线并在x和y范围的坐标中以-1到1显示曲线。



[更新]

感谢您的建议,有没有办法增加像素或坐标的大小。因为我希望-1到0和0到1是宽可见的,这样我就可以绘制曲线。

[/更新]



我尝试了什么:



TranslateTransform和multipletransform以及使用的PointToClient方法但它不起作用

I need to draw a clothoid curve in panel, but the co ordinate values ranges from -1 to 1 due to cos and sin function. Can anyone tell me how to transform the panel size so that I could draw the clothoid curve and visualize the curve in the coordinates of x and y ranges in -1 to 1.

[Update]
Thanks for your suggestion, is there any way to increase size of pixel or co ordinates. because i want -1 to 0 and 0 to 1 to be wide visible so that i could draw curve.
[/Update]

What I have tried:

TranslateTransform and multipletransform and also used PointToClient method but its not working

推荐答案

嗯,这不是火箭科学:你必须翻译和缩放你的图像(也可以反转y轴)。

假设你的油漆区域有coords:左上角= {X0,Y0} 右下角{X1,Y1} 然后

Well, it is not rocket science: you have to translate and scale your image (inverting the y-axis as well).
Supposing your paint area havs coords: top-left = {X0,Y0}, bottom-right {X1,Y1} then
xf = X0 + (x + 1) * (X1 - X0) / 2
yf = Y1 - (y + 1) * (Y1 - Y0) / 2

其中 {x,y} 是计算的回旋点, {xf,yf} 是它的变形表兄。

Where {x,y} is the computed clothoid point and {xf,yf} is its transformed cousin.


你可以对x和y值应用比例/偏差函数。

You can apply a scale/bias function to x and y values.
// We have f() -> (x, y)
// x Є [-1, 1], y Є [-1, 1]

double x, y; // These variables have their values assigned by the function

double width = panel.Width / 2d;
double height = panel.Height / 2d;

// Scale x in the range [-width / 2, width / 2]
double newX = x * width; 
// Bias x in the range [0, width]
newX += width;

// Similarly

// Scale y in the range [-height / 2, height / 2]
double newY = y * height;
// Bias y in the range [0, height]
newY += height;



如果您的面板不是方形,并且您不希望生成的曲线被缩放,那么您必须选择两个因子宽度和高度,并使用此值作为x和y的缩放系数。



希望这会有所帮助。亲切。


In case your panel is not square, and you do not want the resulting curve to be distorded, then you have to choose the least between both factors width and height, and use this one as the scaling factor for x and y.

Hope this helps. Kindly.


感谢您的建议,有没有办法增加像素或坐标的大小。因为我希望-1到0和0到1是宽可见的,这样我就可以绘制曲线。
Thanks for your suggestion, is there any way to increase size of pixel or co ordinates. because i want -1 to 0 and 0 to 1 to be wide visible so that i could draw curve.


这篇关于以窗体形式绘制回旋曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆