<?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 Convert list of 3d points to 2d points? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608549#M67760</link>
    <description>Hi. I am using this to convert a list of 3d points to 2d points (z=0.0), and was wondering if there was a simpler way:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
List&amp;lt;Point3d&amp;gt; my3dPoints = new List&amp;lt;Point3d&amp;gt;();&lt;BR /&gt;
// added points to above&lt;BR /&gt;
List&amp;lt;Point2d&amp;gt; my2dPoints = new List&amp;lt;Point2d&amp;gt;();&lt;BR /&gt;
foreach( Point3d pnt in my3dPoints )&lt;BR /&gt;
    my2dPoints.Add( pnt.Convert2d( new Plane() ) );&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}</description>
    <pubDate>Tue, 29 Dec 2009 07:40:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-12-29T07:40:49Z</dc:date>
    <item>
      <title>Convert list of 3d points to 2d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608549#M67760</link>
      <description>Hi. I am using this to convert a list of 3d points to 2d points (z=0.0), and was wondering if there was a simpler way:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
List&amp;lt;Point3d&amp;gt; my3dPoints = new List&amp;lt;Point3d&amp;gt;();&lt;BR /&gt;
// added points to above&lt;BR /&gt;
List&amp;lt;Point2d&amp;gt; my2dPoints = new List&amp;lt;Point2d&amp;gt;();&lt;BR /&gt;
foreach( Point3d pnt in my3dPoints )&lt;BR /&gt;
    my2dPoints.Add( pnt.Convert2d( new Plane() ) );&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}</description>
      <pubDate>Tue, 29 Dec 2009 07:40:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608549#M67760</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-29T07:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert list of 3d points to 2d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608550#M67761</link>
      <description>This may not come out right because the Autodesk discussion group software mangles code (isn't that just wonderful?).&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
      List&lt;POINT3D&gt; pnt3dList = new List&lt;POINT3D&gt;();&lt;BR /&gt;
&lt;BR /&gt;
      // add items to pnt3dList&lt;BR /&gt;
&lt;BR /&gt;
      List&lt;POINT2D&gt; pnt2dList = pnt3dList.ConvertAll( p =&amp;gt; new Point2d( p.X, p.Y ) );&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
For a simple conversion (e.g, Z = 0.0), don't use Convert2d()&lt;BR /&gt;
because it transforms the input point into the plane argument.&lt;BR /&gt;
It's more efficient to just return a new Point2d.&lt;BR /&gt;
&lt;BR /&gt;
Also, if your list of points is logically a set (e.g., no two elements&lt;BR /&gt;
are coincident) and not order-dependent, you should probably&lt;BR /&gt;
use a HashSet rather than a List.&lt;BR /&gt;
&lt;BR /&gt;
In that case, you can use the Linq Select() method just like the&lt;BR /&gt;
ConvertAll() method is used on the List example above:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
    HashSet&lt;POINT3D&gt; points3d = new HashSet&lt;POINT3D&gt;();&lt;BR /&gt;
&lt;BR /&gt;
    HashSet&lt;POINT2D&gt; points2d = new HashSet&lt;POINT2D&gt;(&lt;BR /&gt;
        points3d.Select( p =&amp;gt; new Point2d( p.X, p.Y ) ) );&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;REBAR0&gt; wrote in message news:6309926@discussion.autodesk.com...&lt;BR /&gt;
Hi. I am using this to convert a list of 3d points to 2d points (z=0.0), and was wondering if there was a simpler way:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
List&lt;POINT3D&gt; my3dPoints = new List&lt;POINT3D&gt;();&lt;BR /&gt;
// added points to above&lt;BR /&gt;
List&lt;POINT2D&gt; my2dPoints = new List&lt;POINT2D&gt;();&lt;BR /&gt;
foreach( Point3d pnt in my3dPoints )&lt;BR /&gt;
my2dPoints.Add( pnt.Convert2d( new Plane() ) );&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;/POINT2D&gt;&lt;/POINT2D&gt;&lt;/POINT3D&gt;&lt;/POINT3D&gt;&lt;/REBAR0&gt;&lt;/POINT2D&gt;&lt;/POINT2D&gt;&lt;/POINT3D&gt;&lt;/POINT3D&gt;&lt;/POINT2D&gt;&lt;/POINT3D&gt;&lt;/POINT3D&gt;</description>
      <pubDate>Tue, 29 Dec 2009 08:08:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608550#M67761</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-29T08:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert list of 3d points to 2d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608551#M67762</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;I see that Tony has answered you, &lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;but you may also want to have a look at this &lt;BR /&gt;
discussion.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;A&gt;&lt;BR /&gt;
title="http://www.theswamp.org/index.php?topic=31404.0
CTRL + Click to follow link" &lt;BR /&gt;
href="http://www.theswamp.org/index.php?topic=31404.0"&amp;gt;http://www.theswamp.org/index.php?topic=31404.0&lt;/A&gt;&amp;nbsp; &lt;BR /&gt;
&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Topic: lambda expression to convert &lt;BR /&gt;
lists&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Regards&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Kerry Brown&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;"rebar0" wrote in message &lt;A&gt;&lt;BR /&gt;
title="news:6309926@discussion.autodesk.com
CTRL + Click to follow link" &lt;BR /&gt;
href="news:6309926@discussion.autodesk.com"&amp;gt;news:6309926@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;Hi. &lt;BR /&gt;
I am using this to convert a list of 3d points to 2d points (z=0.0), and was &lt;BR /&gt;
wondering if there was a simpler way:&lt;BR /&gt;&lt;BR /&gt;{code}&lt;BR /&gt;List&amp;lt;Point3d&amp;gt; &lt;BR /&gt;
my3dPoints = new List&amp;lt;Point3d&amp;gt;();&lt;BR /&gt;// added points to &lt;BR /&gt;
above&lt;BR /&gt;List&amp;lt;Point2d&amp;gt; my2dPoints = new List&amp;lt;Point2d&amp;gt;();&lt;BR /&gt;foreach( &lt;BR /&gt;
Point3d pnt in my3dPoints )&lt;BR /&gt;my2dPoints.Add( pnt.Convert2d( new Plane() ) &lt;BR /&gt;
);&lt;BR /&gt;{code}&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;{code}
&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Dec 2009 08:26:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608551#M67762</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-29T08:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert list of 3d points to 2d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608552#M67763</link>
      <description>Ouch!!!!! &lt;G&gt;&lt;BR /&gt;
&lt;BR /&gt;
If one needs to convert a list of TInput to a list of TOutput, why would they use ForEach() rather than ConvertAll() ?&lt;BR /&gt;
&lt;BR /&gt;
If you look at the implementation of ConvertAll() with Reflector, you might note that it sets the initial capacity of the result &lt;BR /&gt;
list to the size of the input list, which is something one should always do when the number of elements they're working with is &lt;BR /&gt;
known, to avoid the need for the list to incrementally reallocate its internal array each time it must grow in capacity.&lt;BR /&gt;
&lt;BR /&gt;
For another thing, using ForEach() that way also breaks a fundamental rule of FP, that would effectively prevent it from being &lt;BR /&gt;
easily parallelized.&lt;BR /&gt;
&lt;BR /&gt;
BTW, ConvertAll() can thought of as a functional equivalent to AutoLISP's (mapcar) when used with only a single list argument.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
"Kerry Brown" &lt;KDUB&gt; wrote in message news:6309941@discussion.autodesk.com...&lt;BR /&gt;
I see that Tony has answered you,&lt;BR /&gt;
but you may also want to have a look at this discussion.&lt;BR /&gt;
http://www.theswamp.org/index.php?topic=31404.0&lt;BR /&gt;
Topic: lambda expression to convert lists&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Kerry Brown&lt;BR /&gt;
&lt;BR /&gt;
"rebar0" wrote in message news:6309926@discussion.autodesk.com...&lt;BR /&gt;
Hi. I am using this to convert a list of 3d points to 2d points (z=0.0), and was wondering if there was a simpler way:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
List&lt;POINT3D&gt; my3dPoints = new List&lt;POINT3D&gt;();&lt;BR /&gt;
// added points to above&lt;BR /&gt;
List&lt;POINT2D&gt; my2dPoints = new List&lt;POINT2D&gt;();&lt;BR /&gt;
foreach( Point3d pnt in my3dPoints )&lt;BR /&gt;
my2dPoints.Add( pnt.Convert2d( new Plane() ) );&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;/POINT2D&gt;&lt;/POINT2D&gt;&lt;/POINT3D&gt;&lt;/POINT3D&gt;&lt;/KDUB&gt;&lt;/G&gt;</description>
      <pubDate>Tue, 29 Dec 2009 18:38:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-list-of-3d-points-to-2d-points/m-p/2608552#M67763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-29T18:38:41Z</dc:date>
    </item>
  </channel>
</rss>

