15,997,960 members
See more:
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
Posted
Updated 26-Nov-17 22:41pm
v2
CPallini 27-Nov-17 4:43am
"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"
You have to increase nothing. Just apply the transformation shown in my solution: it maps the (-1,-1)-(+1,+1) square to form rectangle.

## Solution 1

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
Where {x,y} is the computed clothoid point and {xf,yf} is its transformed cousin.

## Solution 2

You can apply a scale/bias function to x and y values.
C#
// 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;

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.

## Solution 5

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.

Patrice T 27-Nov-17 2:57am
Don't use a solution to comment or ask other question.
To discuss with author if solution, use 'Have a Question or comment?' at bottom of solution. Advantage, author gets notification.
or use Improve question to update your question.