PC Review


Reply
Thread Tools Rate Thread

[.Net 3.0]Point inside a polygon

 
 
Oriane
Guest
Posts: n/a
 
      17th Jul 2008
Hi there,

I'm looking for a boolean method the result of which is true if a 2D point
is *inside* a polygon - anf false otherwise. I suppose that this is existing
in the WPF class like PointCollection, but I can't find it.

Oriane

 
Reply With Quote
 
 
 
 
Linda Liu[MSFT]
Guest
Posts: n/a
 
      17th Jul 2008
Hi Oriane,

You can get the geometry of the Polygon through its RenderedGeometry
property and call the FillContain(Point) method on the returned geometry
object to detect whether the geometry contains the specifed point or not.

The following is a sample:

Geometry geo = this.polygon.RenderedGeometry;
bool result = geo.FillContain(new Point(20,20));

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Oriane
Guest
Posts: n/a
 
      17th Jul 2008
Thank you Linda. I will try...
 
Reply With Quote
 
Linda Liu[MSFT]
Guest
Posts: n/a
 
      21st Jul 2008
Hi Oriane,

How about the problem now? Have you had a chance to try my suggestion?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Oriane
Guest
Posts: n/a
 
      22nd Jul 2008
Hi Linda,
"Linda Liu[MSFT]" <v-(E-Mail Removed)> wrote:
news:(E-Mail Removed)...
> How about the problem now? Have you had a chance to try my suggestion?


Yes but I just realize that this code:

**************************************
System.Windows.Shapes.Polygon p = new Polygon (...);
Geometry geo = p.RenderedGeometry;
**************************************
does not work (at least for me) since the geo object has empty Bounds... The
p object is not empty and filled with these points: Points {29,61;62,94
35,5;62,94 35,5;57,1 29,61;57,1}. So I don't really see what to do.

A very exciting point about WPF is that it provides us with a mathematicl
library (at least for vector calculus), and I just discover that this code
is possible:

void OneStepTowardGoal ( Point3D goal, Point3D currentPos, double dT)
{
Vector v = goal - currentPos;
v.Normalize();
Vector deltaV = v * speed * dT;
this.currentPos += deltaV;
}

which is exactly what I look for.

Best regards


 
Reply With Quote
 
Linda Liu[MSFT]
Guest
Posts: n/a
 
      23rd Jul 2008
Hi Oriane,

Thank you for your reply!

> ...The p object is not empty and filled with these points: Points

{29,61;62,94 35,5;62,94 35,5;57,1 29,61;57,1}.

You may try the following code snippet to see if the problem can be solved:

PathGeometry pathGeo = new PathGeometry();
PathFigure pathFigure = new PathFigure();
PolyLineSegment seg = new PolyLineSegment();
PointCollection ponts = new
PointCollectionConverter().ConvertFromString("62,94 35,5 62,94 35,5 57,1
29,61 57,1") as PointCollection;
seg.Points = ponts;
pathFigure.StartPoint = new Point(29, 61);
pathFigure.Segments.Add(seg);
pathGeo.Figures.Add(pathFigure);
bool r =pathGeo.FillContains(new Point(-10, -10));
r = pathGeo.FillContains(new Point(0, 0));

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Oriane
Guest
Posts: n/a
 
      24th Jul 2008

"Linda Liu[MSFT]" <v-(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Hi Oriane,
>
> Thank you for your reply!
>
>> ...The p object is not empty and filled with these points: Points

> {29,61;62,94 35,5;62,94 35,5;57,1 29,61;57,1}.
>
> You may try the following code snippet to see if the problem can be
> solved:
>
> PathGeometry pathGeo = new PathGeometry();
> PathFigure pathFigure = new PathFigure();
> PolyLineSegment seg = new PolyLineSegment();
> PointCollection ponts = new
> PointCollectionConverter().ConvertFromString("62,94 35,5 62,94 35,5 57,1
> 29,61 57,1") as PointCollection;
> seg.Points = ponts;
> pathFigure.StartPoint = new Point(29, 61);
> pathFigure.Segments.Add(seg);
> pathGeo.Figures.Add(pathFigure);
> bool r =pathGeo.FillContains(new Point(-10, -10));
> r = pathGeo.FillContains(new Point(0, 0));
>
> Hope this helps.

Indeed it has helped !

Thanks

Oriane

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create polygon in power point 2007 =?Utf-8?B?Y291cm9zaA==?= Microsoft Powerpoint 5 26th Sep 2007 01:10 AM
Chart with a plotted point inside an envelope. =?Utf-8?B?ZmV3ZXN0?= Microsoft Excel Charting 2 23rd Jul 2005 05:39 PM
How do I run a program inside Power Point Viewer? =?Utf-8?B?Vmlld2Vy?= Microsoft Powerpoint 1 10th Jun 2005 11:12 PM
Newbee Power point inside aspx. Jensen bredal Microsoft ASP .NET 1 7th Mar 2005 02:19 PM
Keep a point inside a region? Brian Basquille Microsoft C# .NET 4 7th Feb 2005 02:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:31 PM.