Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
How to Transform Sketch points/curves
bartyborris
OS Professional Posts: 11 PRO
First, I am very new to FeatureScript, so please be patient. I need to transform several points in a sketch and have not been able to find any examples or documentation (that I can understand enough to piece together into something useful... yet). My thought was to simply use the 2D rotation matrix, something like what is shown below (which I know will not work!). In general, if someone could point me to where I can find examples on how to do linear algebra like operations (e.g. create matrices and multiply them) and transforms on points/lines/curves within a sketch I would greatly appreciate it. It appears there is lots of functionality (even SVD, which is great!), although I am struggling on how to utilize it.
// create 2D rotation "matrix"<br>const rotMat = [ [cos(angle), -sin(angle)], [sin(angle), cos(angle)] ];<br><br>// create a 2D "vector"<br>var point1 = vector(0 , 1) * inch;<br>// or maybe:<br>var point1 = [0 * inch, 1 * inch];<br><br>// now rotate/transform the vector with the rotation matrix<br>point1 *= rotMat;
0
Comments
which does not work. I knew about the ordering for the matrix and vector, I was just being a little lazy after driving my self nuts trying to figure out what I was doing wrong