hermann on Fri, 09 Feb 2024 04:16:08 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: how to determine normal vector for points on a plane in ℤ³


On 2024-02-07 18:40, hermann@stamm-wilbrandt.de wrote:
Thanks for both answers.

Bill's method only adds a 1 to each vector
Loïc's method does vector subtraction for all vectors.

So I will go with Bill's method:

I used the method to compute the normal of the plane, and the point on plane with minimal distance to origin:

https://github.com/Hermann-SW/GP3D/blob/main/tqf_3D.2.gp#L45-L56

    v=matker(Mat(apply(x->concat(x,1),P~)))[,1];
...
    PO=-v[4]/(norml2(v[1..3]))*v[1..3]~;
    V=v[1..3]~/sqrt(norml2(v[1..3]~));
    jscad.wlog("O = ",PO);
    jscad.wlog("N = ",conv(V));


with this "conv()":

https://github.com/Hermann-SW/GP3D/blob/main/utils.gp#L10-L14

conv(v)={
    t = acos(v[3]);
    r = atan2(v[2],v[1]);
    [rad2deg(r),rad2deg(t)];
}


JSCAD parameter params.plane decides whether plane is shown:

    jscad.wlog("if (params.plane) {");
jscad.wlog(" out.push(colorize(black,translate(O,sphere({radius:0.1}))))"); jscad.wlog(" out.push(colorize([1,1,1,params.alpha],translate(O,rotateZ(degToRad(90+N[0]),rotate([degToRad(N[1]),0,0],cuboid({size: [2*sc+1,2*sc+1,0.02]}))))))");
    jscad.wlog("}");


The small black sphere in plane is vertex O:

https://stamm-wilbrandt.de/images/tqf_3D.2.gp.n_37.jpg

PARI/GP dtermines maximal number of vertices in a plane (with same color) and draws plane (transparant very thin cuboid) throgh them.


So cool to be able to play with qfminim() determined ℤ³ coordinates (for n=37) in jscad.app in the browser.

Again I used my personal website as URL shortener for the 7543 bytes long application/gzip jscad.app data URL. Click, and you can play with the model in your browser:

https://stamm-wilbrandt.de/tqf_3D.2.gp.n_37.html


Regards,

Hermann.