Re: Re: [SVG] [Batik] Polygon Area

"Gurdev Singh [email protected] [svg-developers]" <[email protected]> Wed, 2 Dec 2015 12:53:16 +0530
Newsgroups gmane.text.xml.svg.devel
Message-ID <[email protected]>
--Apple-Mail-8782160B-A8CE-4611-ADC4-0517012135EF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="UTF-8"

Domenico,


Thanks for your reply.
I was surprise to see that calculation re=
sult are also affected by the 'matrix transformation' attached to the eleme=
nts and by 'view-box' as well.


Is there any documentation that can formula=
te all this relationship?


I mean if I calculate the length, it needs to be=
 reprocessed with some factors from matrix and view-box ?


Thanks 
Singh




=
> On Dec 2, 2015, at 1:59 AM, [email protected] [svg-developers] <svg-deve=
[email protected]> wrote:
> 
> It would have been cruel if they hadn't=
 given us an API for the path element!
> 
> The calculation of a polygon le=
ngth:
> 
> // Distance between two points
>   function getP2Pdistance (a, b=
) {
>     return Math.sqrt(Math.pow((b.x - a.x), 2) + Math.pow((b.y - a.y),=
 2));
>   }
> 
> 
>   function perimeter (points) {
>     var p =3D 0;
> 
>=
     for (var i =3D 1; i < points.length; i++) {
>       p +=3D getP2Pdista=
nce(points[i - 1], points[i]);
>     }
>     return p +=3D getP2Pdistance(p=
oints[i - 1], points[0]);
>   }
> 
> points is an array of point objects wi=
th x and y properties. Note: it wouldn't be smart to insert a test for the =
last segment, better add it manually.
> 
> Again, for self-intersecting pol=
ygons, if one needs the external perimeter and not the total length, then o=
ne needs an intersection library, or at least one would be better off with =
to help work out which are the needed points.
> 
> Domenico
> 
> 
> -------=
- Original Message --------
> Subject: [svg-developers] Re: [SVG] [Batik] P=
olygon Area
> From: "[email protected] [svg-developers]"
> <svg-develop=
[email protected]>
> Date: Tue, December 01, 2015 5:10 pm
> To: svg-devel=
[email protected]
> 
>  
> Thanks Domenico,
> 
> How about checking the=
 length of Polygon element ?
> 
> I am using Java Batik and it is having el=
ement type 'SVGOMPolygonElement'.
> If you see SVGOMPathElement, it is havi=
ng GetTotalLength API.
> 
> Surprisingly, there is no such API for SVGOMPol=
ygonElement.
> 
> I will wait for your valuable answer
> 
> Thanks again
> =
Singh
> 
> 
> 

--Apple-Mail-8782160B-A8CE-4611-ADC4-0517012135EF
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit





<head>

<style type="text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title 
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none; 
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">


<!-- |**|begin egp html banner|**| -->

<br><br>

<!-- |**|end egp html banner|**| -->


<div>Domenico,</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Thanks for your reply.</div><div id="AppleMailSignature">I was surprise to see that calculation result are also affected by the 'matrix transformation' attached to the elements and by 'view-box' as well.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Is there any documentation that can formulate all this relationship?</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">I mean if I calculate the length, it needs to be reprocessed with some factors from matrix and view-box ?<br><br><div>Thanks&nbsp;</div><div>Singh</div><div><br></div></div><div><br>On Dec 2, 2015, at 1:59 AM, <a href="mailto:[email protected]">[email protected]</a> [svg-developers] &lt;<a 
 href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>
























 


<span style="display:none">&nbsp;</span>






    <div id="ygrp-text">
      
      
      <p><span style="font-family:Verdana;color:#000000;font-size:10pt;"></span></p><div style="color: rgb(0, 0, 0);font-family: verdana, geneva;font-size: 10pt;" mce="color: #000000; font-family: verdana, geneva; font-size: 10pt;">It would have been cruel if they hadn't given us an API for the path element!</div><div style="color: rgb(0, 0, 0);font-family: verdana, geneva;font-size: 10pt;" mce="color: #000000; font-family: verdana, geneva; font-size: 10pt;"><br></div><div style="color: rgb(0, 0, 0);font-family: verdana, geneva;font-size: 10pt;" mce="color: #000000; font-family: verdana, geneva; font-size: 10pt;">The calculation of a polygon length:</div><div style="color: rgb(0, 0, 0);font-family: verdana, geneva;font-size: 10pt;" mce="color: #000000; font-family: verdana, geneva; font-si
 ze: 10pt;"><br></div><div><font face="verdana, geneva">// Distance between two points</font></div><div><font face="verdana, geneva">&nbsp;&nbsp;</font>function&nbsp;getP2Pdistance (a, b) {</div><div><font face="verdana, geneva">&nbsp; &nbsp; return Math.sqrt(Math.pow((b.x - a.x), 2) + Math.pow((b.y - a.y), 2));</font></div><div><font face="verdana, geneva"></font></div><div><font face="verdana, geneva">&nbsp; }</font></div><div><font face="verdana, geneva"><br></font></div><div><font face="verdana, geneva"><br></font></div><div><font face="verdana, geneva"><span>&nbsp; function&nbsp;</span><span>perimeter (points) {</span></font></div><div><font face="verdana, geneva"><span>&nbsp; &nbsp; var p = 0;</span></font></div><div><font face="verdana, geneva"><span><br></span></font></div><div><f
 ont face="verdana, geneva"><span>&nbsp; &nbsp; for (var i = 1; i &lt; points.length; i++) {</span></font></div><div><font face="verdana, geneva"><span>&nbsp; &nbsp; &nbsp; p += getP2Pdistance(points[i - 1], points[i]);</span></font></div><div><font face="verdana, geneva"><span>&nbsp; &nbsp; }</span></font></div><div><font face="verdana, geneva"><span>&nbsp; &nbsp; return p += getP2Pdistance(points[i - 1], points[0]);</span></font></div><div><font face="verdana, geneva"><span>&nbsp; }</span></font></div><div><br></div><div>points is an array of point objects with x and y properties. Note: it wouldn't be smart to insert a test for the last segment, better add it manually.</div><div><br></div><div>Again, for self-intersecting polygons, if one needs the external perimeter and not the total l
 ength, then one needs an intersection library, or at least one would be better off with to help work out which are the needed points.</div><div><br></div><div>Domenico</div><div><br></div><div><br></div>
<blockquote id="replyBlockquote" webmail="1" style="color: black;font-family: verdana;font-size: 10pt;border-left-width: 2px;border-left-style: solid;border-left-color: blue;margin-left: 8px;" mce="color: black; font-family: verdana; font-size: 10pt; border-left-width: 2px; border-left-style: solid; border-left-color: blue; margin-left: 8px; padding-left: 8px;">
<div id="wmQuoteWrapper">
-------- Original Message --------<br>
Subject: [svg-developers] Re: [SVG] [Batik] Polygon Area<br>
From: "<a href="mailto:[email protected]">[email protected]</a> [svg-developers]"<br>
&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;<br>
Date: Tue, December 01, 2015 5:10 pm<br>
To: <a href="mailto:[email protected]">[email protected]</a><br>
<br>
      <span mce="display:none">&nbsp;</span>  <div id="ygrp-mlmsg" mce="position:relative;"> <div id="ygrp-msg" mce="z-index: 1;">  <div id="ygrp-text"> <div>Thanks&nbsp;<span style="color:rgb(63, 63, 63);" mce="color:#3f3f3f;">Domenico,</span></div><div><span style="color:rgb(63, 63, 63);" mce="color:#3f3f3f;"><br></span></div><div><font color="#3f3f3f">How about checking the length of Polygon element ?</font></div><div><font color="#3f3f3f"><br></font></div><div><font color="#3f3f3f">I am using Java Batik and it is having element type 'SVGOMPolygonElement'.</font></div><div><font color="#3f3f3f">If you see SVGOMPathElement, it is having GetTotalLength API.</font></div><div><font color="#3f3f3f"><br></font></div><div><font color="#3f3f3f">Surprisingly, there is no such API for SVGOMPolygo
 nElement.</font></div><div><font color="#3f3f3f"><br></font></div><div><font color="#3f3f3f">I will wait for your valuable answer</font></div><div><font color="#3f3f3f"><br></font></div><div><font color="#3f3f3f">Thanks again</font></div><div><font color="#3f3f3f">Singh</font></div><div><font color="#3f3f3f"><br></font></div><div><br></div> </div>  <div style="color: #fff;height: 0;"></div>     <mce><!--
 #wmQuoteWrapper #ygrp-mkp  { border: 1px solid #d8d8d8; font-family: Arial; margin: 10px 0; padding: 0 10px; }
 #wmQuoteWrapper #ygrp-mkp hr  { border: 1px solid #d8d8d8; }
 #wmQuoteWrapper #ygrp-mkp #hd  { color: #628c2a; font-size: 85%; font-weight: 700; line-height: 122%; margin: 10px 0; }
 #wmQuoteWrapper #ygrp-mkp #ads  { margin-bottom: 10px; }
 #wmQuoteWrapper #ygrp-mkp .ad  { padding: 0 0; }
 #wmQuoteWrapper #ygrp-mkp .ad p  { margin: 0; }
 #wmQuoteWrapper #ygrp-mkp .ad a  { color: #0000ff; text-decoration: none; }
 #wmQuoteWrapper #ygrp-sponsor #ygrp-lc  { font-family: Arial; }
 #wmQuoteWrapper #ygrp-sponsor #ygrp-lc #hd  { margin: 10px 0px; font-weight: 700; font-size: 78%; line-height: 122%; }
 #wmQuoteWrapper #ygrp-sponsor #ygrp-lc .ad  { margin-bottom: 10px; padding: 0 0; }
 #wmQuoteWrapper #actions  { font-family: Verdana; font-size: 11px; padding: 10px 0; }
 #wmQuoteWrapper #activity  { background-color: #e0ecee; float: left; font-family: Verdana; font-size: 10px; padding: 10px; }
 #wmQuoteWrapper #activity span  { font-weight: 700; }
 #wmQuoteWrapper #activity span:first-child  { text-transform: uppercase; }
 #wmQuoteWrapper #activity span a  { color: #5085b6; text-decoration: none; }
 #wmQuoteWrapper #activity span span  { color: #ff7900; }
 #wmQuoteWrapper #activity span .underline  { text-decoration: underline; }
 #wmQuoteWrapper .attach  { clear: both; display: table; font-family: Arial; font-size: 12px; padding: 10px 0; width: 400px; }
 #wmQuoteWrapper .attach div a  { text-decoration: none; }
 #wmQuoteWrapper .attach img  { border: none; padding-right: 5px; }
 #wmQuoteWrapper .attach label  { display: block; margin-bottom: 5px; }
 #wmQuoteWrapper .attach label a  { text-decoration: none; }
 #wmQuoteWrapper blockquote  { margin: 0 0 0 4px; }
 #wmQuoteWrapper .bold  { font-family: Arial; font-size: 13px; font-weight: 700; }
 #wmQuoteWrapper .bold a  { text-decoration: none; }
 #wmQuoteWrapper dd.last p a  { font-family: Verdana; font-weight: 700; }
 #wmQuoteWrapper dd.last p span  { margin-right: 10px; font-family: Verdana; font-weight: 700; }
 #wmQuoteWrapper dd.last p span.yshortcuts  { margin-right: 0; }
 #wmQuoteWrapper div.attach-table div div a  { text-decoration: none; }
 #wmQuoteWrapper div.attach-table  { width: 400px; }
 #wmQuoteWrapper div.file-title a, #wmQuoteWrapper div.file-title a:active, #wmQuoteWrapper div.file-title a:hover, #wmQuoteWrapper div.file-title a:visited  { text-decoration: none; }
 #wmQuoteWrapper div.photo-title a, #wmQuoteWrapper div.photo-title a:active, #wmQuoteWrapper div.photo-title a:hover, #wmQuoteWrapper div.photo-title a:visited  { text-decoration: none; }
 #wmQuoteWrapper div#ygrp-mlmsg #ygrp-msg p a span.yshortcuts  { font-family: Verdana; font-size: 10px; font-weight: normal; }
 #wmQuoteWrapper .green  { color: #628c2a; }
 #wmQuoteWrapper .MsoNormal  { margin: 0 0 0 0; }
 #wmQuoteWrapper o  { font-size: 0; }
 #wmQuoteWrapper #photos div  { float: left; width: 72px; }
 #wmQuoteWrapper #photos div div  { border: 1px solid #666666; height: 62px; overflow: hidden; width: 62px; }
 #wmQuoteWrapper #photos div label  { color: #666666; font-size: 10px; overflow: hidden; text-align: center; white-space: nowrap; width: 64px; }
 #wmQuoteWrapper #reco-category  { font-size: 77%; }
 #wmQuoteWrapper #reco-desc  { font-size: 77%; }
 #wmQuoteWrapper .replbq  { margin: 4px; }
 #wmQuoteWrapper #ygrp-actbar div a:first-child  { /* border-right: 0px solid #000;*/ margin-right: 2px; padding-right: 5px; }
 #wmQuoteWrapper #ygrp-mlmsg  { font-size: 13px; font-family: Arial, helvetica,clean, sans-serif; *font-size: small; *font: x-small; }
 #wmQuoteWrapper #ygrp-mlmsg table  { font-size: inherit; font: 100%; }
 #wmQuoteWrapper #ygrp-mlmsg select, #wmQuoteWrapper input, #wmQuoteWrapper textarea  { font: 99% Arial, Helvetica, clean, sans-serif; }
 #wmQuoteWrapper #ygrp-mlmsg pre, #wmQuoteWrapper code  { font:115% monospace; *font-size:100%; }
 #wmQuoteWrapper #ygrp-mlmsg *  { line-height: 1.22em; }
 #wmQuoteWrapper #ygrp-mlmsg #logo  { padding-bottom: 10px; }
 #wmQuoteWrapper #ygrp-msg p a  { font-family: Verdana; }
 #wmQuoteWrapper #ygrp-msg p#attach-count span  { color: #1E66AE; font-weight: 700; }
 #wmQuoteWrapper #ygrp-reco #reco-head  { color: #ff7900; font-weight: 700; }
 #wmQuoteWrapper #ygrp-reco  { margin-bottom: 20px; padding: 0px; }
 #wmQuoteWrapper #ygrp-sponsor #ov li a  { font-size: 130%; text-decoration: none; }
 #wmQuoteWrapper #ygrp-sponsor #ov li  { font-size: 77%; list-style-type: square; padding: 6px 0; }
 #wmQuoteWrapper #ygrp-sponsor #ov ul  { margin: 0; padding: 0 0 0 8px; }
 #wmQuoteWrapper #ygrp-text  { font-family: Georgia; }
 #wmQuoteWrapper #ygrp-text p  { margin: 0 0 1em 0; }
 #wmQuoteWrapper #ygrp-text tt  { font-size: 120%; }
 #wmQuoteWrapper #ygrp-vital ul li:last-child  { border-right: none !important; }
--></mce>     
</div>
</div></div></blockquote>
<p></p>


    </div>
     


    










<!-- end group email -->


</div></blockquote>



<!-- |**|begin egp html banner|**| -->

<br>


<br>

<!-- |**|end egp html banner|**| -->


<div width="1" style="color: white; clear: both;"/>__._,_.___</div>

      
  

    
    <div id="fromDMARC" style="clear:both; margin-top: 10px;">
         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
         Posted by: Gurdev Singh &lt;[email protected]&gt;         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
    </div>
<!-- Start Recommendations -->
<!-- End Recommendations -->


<!-- |**|begin egp html banner|**| -->

<br><br>
<tt>
-----<BR>
To unsubscribe send a message to: [email protected]<BR>
-or-<BR>
visit <a href="http://groups.yahoo.com/group/svg-developers">http://groups.yahoo.com/group/svg-developers</a> and click &quot;edit my membership&quot;<BR>
----</tt>
<br><br>

<!-- |**|end egp html banner|**| -->



<!-- |**|begin egp html banner|**| -->

  <img src="http://geo.yahoo.com/serv?s=97476590/grpId=1298421/grpspId=1706030390/msgId=66503/stime=1449183242" width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->

    
<!-- |**|begin egp html banner|**| -->

<br>



   
     
 
        <!-- |**|begin egp html banner|**| -->
        <div id="ygrp-vital" style="background-color: #f2f2f2; font-family: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">

        <span id="vithd" style="font-weight: bold; color: #333; text-transform: uppercase; "><a href="https://groups.yahoo.com/neo/groups/svg-developers/info;_ylc=X3oDMTJlY2k0cGs5BF9TAzk3MzU5NzE0BGdycElkAzEyOTg0MjEEZ3Jwc3BJZAMxNzA2MDMwMzkwBHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ0OTE4MzI0MQ--" style="text-decoration: none;">Visit Your Group</a></span>

     <ul style="list-style-type: none; margin: 0; padding: 0; display: inline;">
            <li style="border-right: 1px solid #000; font-weight: 700; display: inline; padding: 0 5px; margin-left: 0;">
      <span class="cat"><a href="https://groups.yahoo.com/neo/groups/svg-developers/members/all;_ylc=X3oDMTJmbmt0MnUwBF9TAzk3MzU5NzE0BGdycElkAzEyOTg0MjEEZ3Jwc3BJZAMxNzA2MDMwMzkwBHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0NDkxODMyNDE-" style="text-decoration: none;">New Members</a></span>
      <span class="ct" style="color: #ff7900;">1</span>
    </li>
                                              </ul>
  </div>


<div id="ft" style="font-family: Arial; font-size: 11px; margin-top: 5px; padding: 0 2px 0 0; clear: both;">
  <a href="https://groups.yahoo.com/neo;_ylc=X3oDMTJkODRvaWphBF9TAzk3NDc2NTkwBGdycElkAzEyOTg0MjEEZ3Jwc3BJZAMxNzA2MDMwMzkwBHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDQ5MTgzMjQy" style="float: left;"><img src="http://l.yimg.com/ru/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height="15" width="137" alt="Yahoo! Groups" style="border: 0;"/></a>
  <div style="color: #747575; float: right;"> &bull; <a href="https://info.yahoo.com/privacy/us/yahoo/groups/details.html" style="text-decoration: none;">Privacy</a> &bull; <a href="mailto:[email protected]?subject=Unsubscribe" style="text-decoration: none;">Unsubscribe</a> &bull; <a href="https://info.yahoo.com/legal/us/yahoo/utos/terms/" style="text-decoration: none;">Terms of Use</a> </div>
</div>

<!-- |**|end egp html banner|**| -->

  </div> <!-- ygrp-msg -->

   


  <br>

<!-- |**|end egp html banner|**| -->


<div style="color: white; clear: both;"/>__,_._,___</div>
</body></html>
--Apple-Mail-8782160B-A8CE-4611-ADC4-0517012135EF--