Jump to content

I need to insert a point on a primitive...


Masoud

Recommended Posts

// RunOver: Detail
vector a = point(1, "P", 0);
vector b = point(1, "P", 1);
vector ab = normalize(b - a);

vector c = point(2, "P", 0);
vector d = point(2, "P", 1);
vector cd = normalize(d - c);

vector ac = c - a;

float d1 = (dot(ab, ac) - dot(ac, cd) * dot(ab, cd)) / (1 - dot(ab, cd) * dot(ab, cd));

vector p1 = a + ab * d1;
int pt1 = addpoint(0, p1);

float d2 = (dot(ab, ac) * dot(ab, cd) - dot(cd, ac)) / (1 - dot(ab, cd) * dot(ab, cd));

vector p2 = c + cd * d2;
int pt2 = addpoint(0, p2);
int prim = addprim(0, "polyline");
addvertex(0, prim, pt1);
addvertex(0, prim, pt2);

setpointattrib(0, "Cd", pt1, set(1,0.5,0));
setpointattrib(0, "Cd", pt2, set(1,0.5,0));

//printf('d1:' + sprintf('%g', d1) + '\n');

@Masoud Maybe

t.gif

Edited by Librarian
Link to comment
Share on other sites

Hi Tesan,

Thanks for sharing your code. When I run it on my end, the result looks like what’s shown in the image below. However, I’m having trouble understanding your key points and the intended workflow. It would be really helpful if you could attach your sample scene as well. That way, I can ensure I’m working with the same setup and getting the same results you're seeing.
Also, I’m planning to run this over thousands of lines, so having a clear reference would really help streamline the process.

Thanks in advance!

 

Test.jpg

Edited by Masoud
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...