<?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 Re: (MEL) getting hard angled cvs ? in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9560096#M5925</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jonahrnhrt_2-1591272022509.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779747i33AB6EB7AA46E0ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jonahrnhrt_2-1591272022509.png" alt="jonahrnhrt_2-1591272022509.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When you have two or more CVs on top of each other the tangents are not reliable, for that last point the angle between the two tangents is greater than 90. You'll have to use a different method, like comparing the angle between the point on the curve and a point slightly behind it and ahead of it (rather than using the next CV position).&amp;nbsp; So you'll need to use two short secants instead of tangents.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jonahrnhrt_3-1591272287453.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779751i2B59ECE0A82625C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jonahrnhrt_3-1591272287453.png" alt="jonahrnhrt_3-1591272287453.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 12:07:26 GMT</pubDate>
    <dc:creator>jmreinhart</dc:creator>
    <dc:date>2020-06-04T12:07:26Z</dc:date>
    <item>
      <title>(MEL) getting hard angled cvs ?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9556470#M5921</link>
      <description>&lt;LI-CODE lang="general"&gt;{
 string $selected[] = `ls -sl`;
 string $shapes[];
 float $uParam[];
 vector $cvNormal[];
 string $hardCV[];
 
 for ($curve in $selected)
 {
    int $CVs =`getAttr ($curve + ".spans")`;
    $shapes = `listRelatives -shapes $curve`;
    string $nearestInfo = `createNode nearestPointOnCurve`;
    connectAttr -force ($shapes[0] + ".worldSpace") ($nearestInfo +".inputCurve");
    for ($x = 0; $x &amp;lt; $CVs; $x++)
    {
        vector $location = `pointPosition ($curve + ".cv[" + $x + "]")`;
        setAttr ($nearestInfo + ".inPositionX") ($location.x);
        setAttr ($nearestInfo + ".inPositionY") ($location.y) ;
        setAttr ($nearestInfo + ".inPositionZ") ($location.z) ;
        $uParam[$x] = `getAttr ($nearestInfo + ".parameter")`;  //getAttr nearestPointOnCurve1.parameter;
        $cvNormal[$x] = `pointOnCurve -pr $uParam[$x] -nn $curve`; //get cv normal vector
        //print ($Parameter + "\n");
        //print ($cvNormal[$x] + "\n");
    }
    delete $nearestInfo;
    if (`getAttr ($shapes[0] + ".form")` == 0)
    {
        for ($y = 0; $y &amp;lt; ($CVs - 1); $y++)
        {
            vector $vec1 = $cvNormal[$y];
            vector $vec2 = $cvNormal[($y + 2)];
            float $angle[] = `angleBetween -v1 ($vec1.x) ($vec1.y) ($vec1.z) -v2 ($vec2.x) ($vec2.y) ($vec2.z)`;
            print ($angle[$y] + "\n");
            if (equivalentTol (90.0, $angle[4], 10) == 1){
            $hardCV[size($hardCV)] = ($curve + ".cv[" + ($y + 1)+ "]");
            }
            //print $hardCV[size($hardCV)]; 
        }
    }
 }   
} &lt;/LI-CODE&gt;&lt;P&gt;this is the code that i came up with. In theory its should give me the hard angled cvs. Not quite sure what i did wrong. Im not getting any useful angles from the angleBetween command.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 02:17:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9556470#M5921</guid>
      <dc:creator>absoluteKelvin</dc:creator>
      <dc:date>2020-06-03T02:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: (MEL) getting hard angled cvs ?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9558035#M5922</link>
      <description>&lt;P&gt;What do you mean by hard-angled cvs? Do you mean CVs where the angle the curve makes is less than 90 degrees.&lt;/P&gt;&lt;P&gt;If that's the case then you'll need to use the tangents of the curve not the normals. The normals are perpendicular to the curve.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jonahrnhrt_0-1591198412228.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779358iDC9939C8C22DE4A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jonahrnhrt_0-1591198412228.png" alt="jonahrnhrt_0-1591198412228.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 15:36:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9558035#M5922</guid>
      <dc:creator>jmreinhart</dc:creator>
      <dc:date>2020-06-03T15:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: (MEL) getting hard angled cvs ?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9559034#M5923</link>
      <description>&lt;P&gt;&amp;nbsp;ah i see. i will look into getting the tangent.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 23:44:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9559034#M5923</guid>
      <dc:creator>absoluteKelvin</dc:creator>
      <dc:date>2020-06-03T23:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: (MEL) getting hard angled cvs ?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9559153#M5924</link>
      <description>&lt;P&gt;So I made the adjustment to the pointOnCurve cmd to get cv tangent instead.&lt;/P&gt;&lt;P&gt;supposedly it should select these cvs&lt;/P&gt;&lt;P&gt;like this diagram.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curveAngle.JPG" style="width: 673px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779513i85BE75810D66A8A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="curveAngle.JPG" alt="curveAngle.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;instead i got this as a result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curveAngleResult.JPG" style="width: 610px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779514i3D3430E64E6E3363/image-size/large?v=v2&amp;amp;px=999" role="button" title="curveAngleResult.JPG" alt="curveAngleResult.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;{
 string $selected[] = `ls -sl`;
 string $shapes[];
 float $uParam[];
 vector $cvTangent[];
 string $hardCV[];
 
 for ($curve in $selected)
 {
    int $spans =`getAttr ($curve + ".spans")`;
    int $degree = `getAttr ($curve + ".degree")`;
    int $CVs = $spans + $degree;
    $shapes = `listRelatives -shapes $curve`;
    string $nearestInfo = `createNode nearestPointOnCurve`;
    connectAttr -force ($shapes[0] + ".worldSpace") ($nearestInfo +".inputCurve");
    for ($x = 0; $x &amp;lt; $CVs; $x++)
    {
        vector $location = `pointPosition ($curve + ".cv[" + $x + "]")`;
        setAttr ($nearestInfo + ".inPositionX") ($location.x);
        setAttr ($nearestInfo + ".inPositionY") ($location.y) ;
        setAttr ($nearestInfo + ".inPositionZ") ($location.z) ;
        $uParam[$x] = `getAttr ($nearestInfo + ".parameter")`;  //getAttr nearestPointOnCurve1.parameter;
        $cvTangent[$x] = `pointOnCurve -pr $uParam[$x] -tangent $curve`; //get cv tagent
        //print ($uParam[$x] + "\n");
        //print ($cvTangent[$x] + "\n");
    }
    delete $nearestInfo;
    if (`getAttr ($shapes[0] + ".form")` == 0)
    {
        for ($y = 0; $y &amp;lt; ($CVs - 1); $y++)
        {
            vector $vec1 = $cvTangent[$y];
            vector $vec2 = $cvTangent[($y + 2)];
            float $angle[] = `angleBetween -v1 ($vec1.x) ($vec1.y) ($vec1.z) -v2 ($vec2.x) ($vec2.y) ($vec2.z)`;
            print ($angle[3] + "\n");
            if ($angle[3] &amp;gt;= 45){
            $hardCV[size($hardCV)] = ($curve + ".cv[" + ($y + 1)+ "]");
            }
        }
    print $hardCV;
    select -r $hardCV;
    }
 }   
} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 01:23:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9559153#M5924</guid>
      <dc:creator>absoluteKelvin</dc:creator>
      <dc:date>2020-06-04T01:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: (MEL) getting hard angled cvs ?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9560096#M5925</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jonahrnhrt_2-1591272022509.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779747i33AB6EB7AA46E0ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jonahrnhrt_2-1591272022509.png" alt="jonahrnhrt_2-1591272022509.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When you have two or more CVs on top of each other the tangents are not reliable, for that last point the angle between the two tangents is greater than 90. You'll have to use a different method, like comparing the angle between the point on the curve and a point slightly behind it and ahead of it (rather than using the next CV position).&amp;nbsp; So you'll need to use two short secants instead of tangents.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jonahrnhrt_3-1591272287453.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779751i2B59ECE0A82625C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jonahrnhrt_3-1591272287453.png" alt="jonahrnhrt_3-1591272287453.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 12:07:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/mel-getting-hard-angled-cvs/m-p/9560096#M5925</guid>
      <dc:creator>jmreinhart</dc:creator>
      <dc:date>2020-06-04T12:07:26Z</dc:date>
    </item>
  </channel>
</rss>

