Menu

#14 Vector type classes

0.1a
open
5
2005-07-04
2005-01-16
eRom
No

Hi ;)

I looking your package about Vector type.
Interesting...but I think giving possibility to set or
get the 2 or 3 components for a vector with 1 method
could be useful, isn't it ?

For exemple in class Vector2D :
---------------------------------------------
public function setPosition(x:Number, y:Number) : Void {
setX(x);
setY(y);
}

public function getPosition(Void) : Object {
return { _x:getX(), _y:getY() };
}
---------------------------------------------
And the same for Vector3D with adding Z component ;)

Moreever we can use overloading for setting position
with another Vector or with 2 (or 3 for Vector3D) Numbers.

Exemple for Vector2D :
---------------------------------------------
public function setPosition() : Void {
var overload = new Overload(this);
overload.addHandler([Number], [Number],
setPositionByComponent);
overload.addHandler([Vector2D],
setPositionByComponent);
overload.forward(arguments);
}

private function setPositionByComponent(x:Number,
y:Number) : Void {
setX(x);
setY(y);
}

private function setPositionByVector(v:Vector2D) : Void {
setX(v.getX());
setY(v.getY());
}
---------------------------------------------

I think that theses classes are not finished..but it
could be cool to have some mathematics vector
operations, like addition, soustraction, opposite,
division, multiplication, scalar product....

Bye.
eRom

Discussion

  • Martin Heidegger

    Logged In: YES
    user_id=901744

    Vectors are some "not even half ready" product of a part
    time developer of the as2lib. If i would implement it, it
    would work with a array:
    setPositionByCoordinates([x,y,z,....]); or
    setPositionByVector(v:Vector); where it uses all the
    available informations(in this way you could set the 2D
    position of a 3D vector). Its been a long time since i have
    learned about the operations but they might be interesting.
    I try to figure out how to best solve this.

     
  • Martin Heidegger

    • assigned_to: mastakaneda --> ripcurlx
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.