Coder Social home page Coder Social logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 26, 2024
Unfortunately, converting from double (DoublePoint) to float (PointF) is a 
information-losing conversion, and Microsoft's guidelines say that should not 
be done automatically.
Similarly, the removal of IntPoint and DoublePoint would be a breaking change, 
which should be done carefully, if at all.

Language-lawyer tendencies assuaged, I'd vote for breaking changes over 
automatic conversions between various functionally equivalent structures. 
Failing that, I'd also vote for truncating doubles to floats automatically.

If you (AForge devs) are opposed to such things, extension methods to convert 
IEnumerable<IntPoint> to IEnumerable<Point> and IEnumerable<DoublePoint> to 
IEnumerable<PointF> would make the array/list of points issue less problematic; 
it's easy enough to take an IEnumberable and convert it to the desired concrete 
class. Or to just use it as an IEnumerable.

Original comment by [email protected] on 12 Oct 2010 at 4:09

from aforge.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 26, 2024
I really agree that the fact AForge.NET framework has its own IntPoint and 
DoublePoint structures may look awkward and introduce pain. I can explain why 
they came ...

I simple don’t get why MS decided to put Point and PointF into 
Systtem.Drawing namespace.  Why should I reference this assembly and use this 
namespace if don’t want to draw at all? What if I want to create some 
math/geometry/whatever routines, which deal with points, but not with drawing?

Well, maybe the above though is not an excuse to introduce such awkwardness, 
but putting point structures into System.Drawing is not the best idea either.

Original comment by [email protected] on 10 Nov 2010 at 10:51

from aforge.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 26, 2024
The reasoning behinds the decision to provide custom point structures outside 
System.Drawing makes sense. However, I think it would be useful to provide more 
of the methods implemented by System.Drawining.Point/PointF, in particular the 
Empty property to return a zero-valued point, and methods for truncating, 
ceiling and flooring a Point/DoublePoint. They could be marked as 
[Serializable] as well.

By the way, wouldn't it be better if X and Y were exposed as properties instead 
of public fields? Those would be optimized by the compiler anyway.

Original comment by [email protected] on 14 Apr 2011 at 2:20

from aforge.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 26, 2024
>> However, I think it would be useful to provide more of the methods 
implemented
>> by System.Drawining.Point/PointF, in particular the Empty property to return
>> a zero-valued point, and methods for truncating, ceiling and flooring a
>> Point/DoublePoint.
Yep, could be done. You can even submit a patch for this ;)

>> By the way, wouldn't it be better if X and Y were exposed as properties
>> instead of public fields?
We may do it. However the benefit is not that obvious in this particular case. 
Cannot imagine any type of extra code someday appearing in setter. (Take a look 
at XNA code - MS does not bother to create extra properties for simple 
structures like Vector3)

>> Those would be optimized by the compiler anyway.
Only JIT compiler may do it.

Original comment by [email protected] on 17 Apr 2011 at 9:54

from aforge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.