Open rob-777 opened 2 years ago
To rotate a curve You can follow these steps:
Consider your curve the parabolic arc C(u) = a{0} + a{1}u + a_{2}u^2
Define the Matrix: Decide the point that you want to rotate. The point can be any point in the coordinate system.
Rotate the Matrix: Use a rotation matrix to perform the rotation. You can also define the angle of rotation & the axis of rotation (e.g., x-axis, y-axis, z-axis), For 2D, you use 2x2 rotation matrix, for 3D, you use 3x3 rotation matrix.
Here is a brief explanation in pseudo-code for rotating a curve around the origin by an angle theta
/* Define curve points (x, y) */
curve_points[(x0, y0), (x1, y1), (x2, y2)]
/* Define angle of rotation */
theta = x degrees
/* Define rotation matrix */
rotation_matrix = [[cos(theta), -sin(theta)],
[sin(theta), cos(theta)]]
/* Rotate each curve point */
rotated_curve = []
for x, y in curve_points:
x_new = x * cos(theta) - y * sin(theta)
y_new = x * sin(theta) + y * cos(theta)
rotated_curve.append((x_new, y_new))
: ) Not sure is right
Hi,
This is a generic question of how to rotate a polynomial curve. So it is actually not a SISL issue.
The curves in SISL are either B-spline curves or for those you can just rotate the points of the control polygon. For the NURBS curves you must rotate the control points projected to affine space.
For rotation of parametric curves in the power bases you probably can find algorithms in the literature.
Tor
From: ChenXing Wang @.> Sent: Tuesday, February 20, 2024 10:59 To: SINTEF-Geometry/SISL @.> Cc: Subscribed @.***> Subject: Re: [SINTEF-Geometry/SISL] How to rotate a curve ? (Issue #41)
To rotate a curve You can follow these steps:
Here is a brief explanation in pseudo-code for rotating a curve around the origin by an angle theta
/ Define curve points (x, y) /
curve_points[(x0, y0), (x1, y1), (x2, y2)]
/ Define angle of rotation /
theta = x degrees
/ Define rotation matrix /
rotation_matrix = [[cos(theta), -sin(theta)],
[sin(theta), cos(theta)]]
/ Rotate each curve point /
rotated_curve = []
for x, y in curve_points:
x_new = x * cos(theta) - y * sin(theta)
y_new = x * sin(theta) + y * cos(theta)
rotated_curve.append((x_new, y_new))
: ) Not sure is right
- Reply to this email directly, view it on GitHubhttps://github.com/SINTEF-Geometry/SISL/issues/41#issuecomment-1953856906, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABBHBM2PI6LEZKNXR24I33LYURXWBAVCNFSM5TL7KIX2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJVGM4DKNRZGA3A. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>
How can I rotate a curve ?