Jump to content

Orthographic align and move back to original position


Recommended Posts

I am trying to make a setup where I align an object orthographically and then after I do my operations move the result back to the original position.
I have a working way for aligning but am sure there must be an easier way...
My method for aligning now:
- Create oriented bbox
- Measure prims
- delete all but largest, then delete 1 of the largest in order to just have 1 rectangle, 4 points
- make a vector from point 0 to 1 to align with x
- make a vector from 0 to 2 to align with y
- make normals to align with z
- in vops use the align vop to align the 0 1 vector to x then use the (rotated) normals to align with z

Even though this works I assume (hope) there is a better way to find the vectors, using pointnumbers is not procedural enough imho so any tips here would be great.

But then the part I can't seem to get...
How do I rotate my result back to the original position? there must be a way to store the rotations and invert these or something but everything i tried didin't work. my vectormath and matrices could def use some work.
ofcourse i can use a point deform but that would not be accurate enough plus i am 00% sure there must be a way to invert what i did in the first vop.

 

Thanks!

 

Link to comment
Share on other sites

try this one

vector edge_dirs[];
float edge_lengths[];
foreach(int nb; neighbours(0,@ptnum)){
	vector pos = point(0,"P",nb);
	vector delta = pos-@P;
	append(edge_dirs,normalize(delta));
	append(edge_lenghts, length(delta));
}
edge_dirs = reorder(edge_dirs,argsort(edge_lengths));
vector x = edge_dirs[-2];
vector y = edge_dirs[-3];
vector z = edge_dirs[-1]; //longest
3@rot = set(x,y,z);

then find point you like and assign matrix from it for all points and make this: @P *= invert(3@rot); to back to initial position just @P *= 3@rot;

Edited by tamagochy
fix lenghts ))
  • Like 2
Link to comment
Share on other sites

That is awesome, Thanks!
(And I see you suffer from the same issue I have, never knowing how to exactly spell length (haha just wrote it wrong even, thank G'd for google autocorrect) took me a while to figure out why it was erroring as somehow it always looks the same to me)

Link to comment
Share on other sites

On 5/29/2018 at 7:43 PM, sjowol said:

That is awesome, Thanks!
(And I see you suffer from the same issue I have, never knowing how to exactly spell length (haha just wrote it wrong even, thank G'd for google autocorrect) took me a while to figure out why it was erroring as somehow it always looks the same to me)

I don't know what's with that word but several times I to spell it wrong, we may have made a scientific discovery :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...