<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Calculate the angle between two planes in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881781#M104580</link>
    <description>&lt;P&gt;Hi folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 30 discrete points in X, Y, Z defining plane 1, and 30 other points in X, Y, Z defining plane 2, I need to calculate the angle between plane 1 and plane 2. The ChatGPT provides the following JSL script, but it stuck at row #33. Could any of you help check the two attachments (*.jmp and *.jsl) to get this script going? Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Use current data table
dt = Current Data Table();
 
// Subset for Plane1 and Plane2
dt1 = dt &amp;lt;&amp;lt; Subset( Where( :Plane == "Plane1" ), Output Table Name( "Plane1" ) );
dt2 = dt &amp;lt;&amp;lt; Subset( Where( :Plane == "Plane2" ), Output Table Name( "Plane2" ) );
 
// Fit plane 1: z = a1*x + b1*y + c1
b1 = dt1 &amp;lt;&amp;lt; Fit Model(
Y( :Z ),
Effects( :X, :Y ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run( "Fit Model" )
);
coeff1 = b1 &amp;lt;&amp;lt; Get Estimates;
a1 = coeff1["X"];
b1_ = coeff1["Y"];
 
// Fit plane 2: z = a2*x + b2*y + c2
b2 = dt2 &amp;lt;&amp;lt; Fit Model(
Y( :Z ),
Effects( :X, :Y ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run( "Fit Model" )
);
coeff2 = b2 &amp;lt;&amp;lt; Get Estimates;
a2 = coeff2["X"];
b2_ = coeff2["Y"];
 
// Normal vectors: [a, b, -1]
n1 = [a1, b1_, -1];
n2 = [a2, b2_, -1];
 
// Compute dot product and magnitudes
dotProd = Sum( n1 * n2 );
mag1 = Sqrt( Sum( n1 ^ 2 ) );
mag2 = Sqrt( Sum( n2 ^ 2 ) );
 
// Compute angle in degrees
cosTheta = dotProd / (mag1 * mag2);
thetaRad = ACos( cosTheta );
thetaDeg = thetaRad * (180 / Pi());
 
// Display result
New Window( "Angle Between Planes",
Text Box( "Angle (degrees): " || Char( thetaDeg ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jun 2025 04:13:57 GMT</pubDate>
    <dc:creator>TDK_Long</dc:creator>
    <dc:date>2025-06-26T04:13:57Z</dc:date>
    <item>
      <title>Calculate the angle between two planes</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881781#M104580</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 30 discrete points in X, Y, Z defining plane 1, and 30 other points in X, Y, Z defining plane 2, I need to calculate the angle between plane 1 and plane 2. The ChatGPT provides the following JSL script, but it stuck at row #33. Could any of you help check the two attachments (*.jmp and *.jsl) to get this script going? Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Use current data table
dt = Current Data Table();
 
// Subset for Plane1 and Plane2
dt1 = dt &amp;lt;&amp;lt; Subset( Where( :Plane == "Plane1" ), Output Table Name( "Plane1" ) );
dt2 = dt &amp;lt;&amp;lt; Subset( Where( :Plane == "Plane2" ), Output Table Name( "Plane2" ) );
 
// Fit plane 1: z = a1*x + b1*y + c1
b1 = dt1 &amp;lt;&amp;lt; Fit Model(
Y( :Z ),
Effects( :X, :Y ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run( "Fit Model" )
);
coeff1 = b1 &amp;lt;&amp;lt; Get Estimates;
a1 = coeff1["X"];
b1_ = coeff1["Y"];
 
// Fit plane 2: z = a2*x + b2*y + c2
b2 = dt2 &amp;lt;&amp;lt; Fit Model(
Y( :Z ),
Effects( :X, :Y ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run( "Fit Model" )
);
coeff2 = b2 &amp;lt;&amp;lt; Get Estimates;
a2 = coeff2["X"];
b2_ = coeff2["Y"];
 
// Normal vectors: [a, b, -1]
n1 = [a1, b1_, -1];
n2 = [a2, b2_, -1];
 
// Compute dot product and magnitudes
dotProd = Sum( n1 * n2 );
mag1 = Sqrt( Sum( n1 ^ 2 ) );
mag2 = Sqrt( Sum( n2 ^ 2 ) );
 
// Compute angle in degrees
cosTheta = dotProd / (mag1 * mag2);
thetaRad = ACos( cosTheta );
thetaDeg = thetaRad * (180 / Pi());
 
// Display result
New Window( "Angle Between Planes",
Text Box( "Angle (degrees): " || Char( thetaDeg ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jun 2025 04:13:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881781#M104580</guid>
      <dc:creator>TDK_Long</dc:creator>
      <dc:date>2025-06-26T04:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the angle between two planes</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881794#M104582</link>
      <description>&lt;P&gt;No idea about the rest of the script, but line 33 isn't written in JSL.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n1 = [a1, b1_, -1];
n2 = [a2, b2_, -1];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Probably should be more like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n1 = a1 ||  b1_ || -1;
 or perhaps
n2 = a2 |/ b2_ |/ -1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the n1 example should make a row vector and the n2 make a col vector.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 00:30:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881794#M104582</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-06-26T00:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the angle between two planes</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881795#M104583</link>
      <description>&lt;P&gt;And the dot product is probably wrong too, you should look it up and figure out if JMP's element-wise multiply is what you need; the * is a matrix multiply which might not be the operator you need.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 00:37:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-the-angle-between-two-planes/m-p/881795#M104583</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-06-26T00:37:44Z</dc:date>
    </item>
  </channel>
</rss>

