Supposing your paint area havs coords:

`top-left = {X0,Y0}`

, `bottom-right {X1,Y1}`

thenxf = X0 + (x + 1) * (X1 - X0) / 2 yf = Y1 - (y + 1) * (Y1 - Y0) / 2Where

`{x,y}`

is the computed clothoid point and `{xf,yf}`

is its transformed cousin.
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

[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]

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

Comments

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:

Supposing your paint area havs coords:

`top-left = {X0,Y0}`

, `bottom-right {X1,Y1}`

thenxf = X0 + (x + 1) * (X1 - X0) / 2 yf = Y1 - (y + 1) * (Y1 - Y0) / 2Where

`{x,y}`

is the computed clothoid point and `{xf,yf}`

is its transformed cousin.
Permalink

Share this answer

You can apply a scale/bias function to x and y values.

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.

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.

Permalink

Share this answer

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.

Permalink

Share this answer

Comments

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.

To discuss with author if solution, use 'Have a Question or comment?' at bottom of solution. Advantage, author gets notification.

or use

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900

"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.