Help with rotating direction vector along unit circle

3 visualizzazioni (ultimi 30 giorni)
Brian
Brian il 12 Feb 2016
Modificato: Brian il 12 Feb 2016
Hello, thanks for reading this,
I think I'm overthinking this particular problem. What I'm doing is generating a binary tree in 2D, and what I want to do is limit the angle in which each segments bifurcates into a pre-defined range (30 to 50 degrees, for example).
This is what I have, as a simple example, in the attached matlab_example.m
You can see from the example, I have three points with two direction vectors V1 and V2, and from V1 and V2 I have a angle between the two direction vectors. In this specific case, the angle is about 22 degrees, but I want it to be contained, for example, between 30 and 50 degrees (meaning lower than 30 gets increased to 30 degrees, and greater than 50 degrees gets reduced to 30 degrees).
How would I go about doing that? This is what I think would be easiest:
If I translate ptMx by ptMx(1,:) and rotate the ptMx and direction vectors V1, V2 by svd(V1,0) then I can get rotated_V1 and rotated_V2 which are rotated in a way that V1 will be parallel along the x-axis. In that case,
ptMx(2,1) = ptMx(1,:) + V1, and
ptMx(3,:) = ptMx(2,:) + [norm(V2) * cos(22) norm(V2) * sin(22)], where 22 is the orig. bif angle
since I have this along the x-axis, the x-component of ptMx(3,:) will be the norm of V2 times the cos of the bif angle (which again is ~22 degrees), and the y-component would be the norm of V2 times the sin of the bif angle. If I wanted to limit this to at least 30 degrees, I would simply replace the angle with 30 to get my new x and y coordinates.
My question now is this: would it be possible to do this without translating and rotating the original set of points and direction vectors? I can do this if needed but I was wondering if someone smarter than me would have a better way of doing this.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by