intel / node-realsense

MIT License
24 stars 21 forks source link

Point2D.setCoords(x, y) is very JS-unlike #200

Open kenchris opened 7 years ago

kenchris commented 7 years ago

This seems very much like a C++, Java way of doing things. You have direct access to x and y, so this makes very little sense.

Also I would follow DOMMatrix and add the following ctors:

 Constructor(Float32Array array32),
 Constructor(Float64Array array64),
 Constructor(sequence<unrestricted double> numberSequence),

unrestricted double makes more sense given that JS works with 64bit doubles.

Then you might want to add

    Float32Array        toFloat32Array();
    Float64Array        toFloat64Array();

This will replace getCoords()

I also really wonder how useful the equal() method is. It would be super easy to check if needed.

Also disallow empty ctor

[
 Constructor(unrestricted double x, unrestricted double y),
 Constructor(Float32Array array32),
 Constructor(Float64Array array64),
 Constructor(sequence<unrestricted double> numberSequence)
]
interface Point2D {
  attribute unrestricted double x;
  attribute unrestricted double y;

  static boolean equals(Point2D a, Point2D b);
  static unrestricted double distance(Point2D a, Point2D b);

  Float32Array toFloat32Array();
  Float64Array toFloat64Array();
}

Also I don't see the point of having specific classes for the different sizes... Just do a WorldPoint class or similar instead which allows up to 4 values, just like DOMPoint.

Also don't you have any use-cases for Vectors?