Locating points p3 p4

help with ruby
locating points p3 p4 with p1 and p2
as shown in Figure

Please attach the image properly…

1 Like

Eu mesmo lendo um pouco consegui.
não sei se existe outra maneira.

vetor = p1.vector_to(p2)
a = vetor.axes
v1 = a[0]
v2 = a[1]
v3 = a[2]

p3 = p1.offset(v1,B)
p4 = p3.offset(v2,C)

Obrigado TIG pelo seu interesse.

The objects B and C (in your example) are undefined.

More explanation of what you are attempting to do, is needed.

Do you want p3 to be mid point between p4 and p2?

Do you want p3 to be on a line between the direction of A and C?

Can you explain in more details please to what you are doing?

Considering the segment p1 p2 as being the z axis and the other two segments being x and y axis. What I am trying to achieve is to define p1 and p2 using the cursor and give values to B and C. With the intent to create a shape which is going to be extruded along the z axis.

So
v12=p1.vector_to(p2)
defines the first vector.
I assume you want it to be ‘flat’ ?
If so, after p1 is picked, get p2 and then change:
p2.z=p1.z
Now you have a ‘flat vector’.

The ‘up’ vector is simply set up using:
p3=p1.clone p3.z=p1.z+1
v13=p1.vector_to(p3)

Now to find p4, consider:
v14=v12.cross(v13)
p4=p1.offset(v14)

Now you have the three vectors and four points needed ?
v12, v13, v14 p1, p2, p3, p4

1 Like