12-01-2026, 03:35 AM
(This post was last modified: 12-01-2026, 03:39 AM by Luiz Fonte Boa.)
The idea of user "Ivla" remained on my mind, Micheus. So...
-------------------
Hello Micheus! First of all, thank you for all the continuous hard work and dedication maintaining and improving Wings3D.
In these times of artificial intelligence—and considering the idea of using it as an ally—this whole suggestion actually started while I was just playing around with Google's Gemini AI. To be completely honest, I am just copying and pasting what it gave me here! Haha! So I would love to know from you, dear Micheus, if the structure of these instructions makes any sense at all—because for me, as you know, this is all Greek!
Following up on the original idea brought up by user **IVLA** in the thread https://wings3d.com/forum/showthread.php...n=lastpost, I would like to respectfully suggest a small feature for future consideration: a Vertex | Perpendicular Connect command, which would allow connecting a selected vertex directly to an opposite edge at an exact 90-degree angle.
Just as a starting point or conceptual reference, here is one possible way this could be structured within `src/wings_vertex_cmd.erl`:
### 1. Context Menu Entry (`menu/1`)
Adding the command alongside the existing `Connect` options in Vertex mode:
```erlang
menu(St) ->
[ ...
{?__(10,"Connect"),connect,
?__(11,"Create a new edge by connecting selected vertices")},
{?__(12,"Perpendicular Connect"), perp_connect,
?__(13,"Connect selected vertex perpendicularly (90 deg) to a target edge")},
...
].
```
### 2. Command Routing (`command/2`)
Mapping the `perp_connect` atom to prompt the user for the target edge:
```erlang
command(connect, St) ->
?SLOW(connect(St));
command(perp_connect, St) ->
ask_perp_connect(St);
```
### 3. Orthogonal Projection Logic
Using vector dot product to find the exact 90-degree intersection point on the target edge before splitting and connecting:
```erlang
%%%
%%% Perpendicular Connect (90 degrees)
%%%
ask_perp_connect(St) ->
wings:ask({[{edge, ?__(14,"Select target edge for 90-degree connection")}], []},
St, fun do_perp_connect/2).
do_perp_connect({TargetEdge, _}, #st{sel=[{Id, SelVertices}]} = St) ->
case gb_sets:to_list(SelVertices) of
[VertP] ->
wings_sel:map(
fun(_, #we{id=WeId}=We) when WeId =:= Id ->
apply_perp_cut(VertP, TargetEdge, We);
(_, We) ->
We
end, St);
_ ->
wings_u:error_msg(?__(15,"Select exactly ONE source vertex first."))
end;
do_perp_connect(_, _) ->
wings_u:error_msg(?__(16,"Select one vertex in a single object.")).
apply_perp_cut(VertP, Edge, #we{vp=Vtab, es=Etab}=We0) ->
#edge{vs=VertA, ve=VertB} = array:get(Edge, Etab),
PosP = array:get(VertP, Vtab),
PosA = array:get(VertA, Vtab),
PosB = array:get(VertB, Vtab),
AB = e3d_vec
ub(PosB, PosA),
AP = e3d_vec
ub(PosP, PosA),
LenSq = e3d_vec:dot(AB, AB),
case LenSq > 1.0e-12 of
true ->
T = e3d_vec:dot(AP, AB) / LenSq,
if
T > 0.0001 andalso T < 0.9999 ->
PosQ = e3d_vec:add(PosA, e3d_vec:mul(AB, T)),
{We1, VertQ} = wings_edge:fast_cut(Edge, PosQ, We0),
{We2, _NewSel} = wings_vertex:connect(VertP, [VertQ], We1),
We2;
true ->
wings_u:error_msg(?__(17,"Perpendicular point falls outside the edge segment."))
end;
false ->
wings_u:error_msg(?__(18,"Target edge has zero length."))
end.
```
*(Note: I also realize there are three tricky edge cases to keep in mind: ensuring both the vertex and target edge actually share the same face, handling non-planar faces where a 90° cut might create an unexpected crease, and obtuse angles where the perpendicular projection falls outside the edge segment).*
Of course, you know the internal architecture and edge-case conventions of Wings3D far better than I do, so please feel free to adapt or disregard this snippet as you see fit. Thank you again for your time and for keeping Wings3D such a great tool!
-------------------
Hello Micheus! First of all, thank you for all the continuous hard work and dedication maintaining and improving Wings3D.
In these times of artificial intelligence—and considering the idea of using it as an ally—this whole suggestion actually started while I was just playing around with Google's Gemini AI. To be completely honest, I am just copying and pasting what it gave me here! Haha! So I would love to know from you, dear Micheus, if the structure of these instructions makes any sense at all—because for me, as you know, this is all Greek!
Following up on the original idea brought up by user **IVLA** in the thread https://wings3d.com/forum/showthread.php...n=lastpost, I would like to respectfully suggest a small feature for future consideration: a Vertex | Perpendicular Connect command, which would allow connecting a selected vertex directly to an opposite edge at an exact 90-degree angle.
Just as a starting point or conceptual reference, here is one possible way this could be structured within `src/wings_vertex_cmd.erl`:
### 1. Context Menu Entry (`menu/1`)
Adding the command alongside the existing `Connect` options in Vertex mode:
```erlang
menu(St) ->
[ ...
{?__(10,"Connect"),connect,
?__(11,"Create a new edge by connecting selected vertices")},
{?__(12,"Perpendicular Connect"), perp_connect,
?__(13,"Connect selected vertex perpendicularly (90 deg) to a target edge")},
...
].
```
### 2. Command Routing (`command/2`)
Mapping the `perp_connect` atom to prompt the user for the target edge:
```erlang
command(connect, St) ->
?SLOW(connect(St));
command(perp_connect, St) ->
ask_perp_connect(St);
```
### 3. Orthogonal Projection Logic
Using vector dot product to find the exact 90-degree intersection point on the target edge before splitting and connecting:
```erlang
%%%
%%% Perpendicular Connect (90 degrees)
%%%
ask_perp_connect(St) ->
wings:ask({[{edge, ?__(14,"Select target edge for 90-degree connection")}], []},
St, fun do_perp_connect/2).
do_perp_connect({TargetEdge, _}, #st{sel=[{Id, SelVertices}]} = St) ->
case gb_sets:to_list(SelVertices) of
[VertP] ->
wings_sel:map(
fun(_, #we{id=WeId}=We) when WeId =:= Id ->
apply_perp_cut(VertP, TargetEdge, We);
(_, We) ->
We
end, St);
_ ->
wings_u:error_msg(?__(15,"Select exactly ONE source vertex first."))
end;
do_perp_connect(_, _) ->
wings_u:error_msg(?__(16,"Select one vertex in a single object.")).
apply_perp_cut(VertP, Edge, #we{vp=Vtab, es=Etab}=We0) ->
#edge{vs=VertA, ve=VertB} = array:get(Edge, Etab),
PosP = array:get(VertP, Vtab),
PosA = array:get(VertA, Vtab),
PosB = array:get(VertB, Vtab),
AB = e3d_vec
ub(PosB, PosA),AP = e3d_vec
ub(PosP, PosA),LenSq = e3d_vec:dot(AB, AB),
case LenSq > 1.0e-12 of
true ->
T = e3d_vec:dot(AP, AB) / LenSq,
if
T > 0.0001 andalso T < 0.9999 ->
PosQ = e3d_vec:add(PosA, e3d_vec:mul(AB, T)),
{We1, VertQ} = wings_edge:fast_cut(Edge, PosQ, We0),
{We2, _NewSel} = wings_vertex:connect(VertP, [VertQ], We1),
We2;
true ->
wings_u:error_msg(?__(17,"Perpendicular point falls outside the edge segment."))
end;
false ->
wings_u:error_msg(?__(18,"Target edge has zero length."))
end.
```
*(Note: I also realize there are three tricky edge cases to keep in mind: ensuring both the vertex and target edge actually share the same face, handling non-planar faces where a 90° cut might create an unexpected crease, and obtuse angles where the perpendicular projection falls outside the edge segment).*
Of course, you know the internal architecture and edge-case conventions of Wings3D far better than I do, so please feel free to adapt or disregard this snippet as you see fit. Thank you again for your time and for keeping Wings3D such a great tool!