Yes because basically the ray object just holds two points [...]
The ray has a member named "origin" and a member named "direction". While the type of the origin is a point vector, the type of the direction is, well, a direction vector. A direction vector is the difference vector from one point to another and, usually also normalized in its length. Defining a ray that way is natural since a ray is a directed infinite long line. The formula I've chosen to describe the ray in one of the posts above reflects this, i.e.
r( k ) = v1 + k * v2
where v1 is the origin (a point) and v2 is the direction. Since a point plus a difference vector gives again a point, the formula describes well an infinite set of points that together give the ray.
[…] and i didn't want to create another object
Since your line segments use the same class, they naturally fall into the same interpretation. It is not good practice to interpret the same class in different ways just at will. As you can see here, all my posts have been written under the assumption that the variable names stand for what commonly is understood for them, and foremost that they are interpreted uniformly.
[…] because now my segments are not displayed the way i wanted them to be, aren't they?
To solve this, if your line segment goes from point p1 to point p2, and you want to use the ray class to store it, then convert (p1,p2) into a ray like so:
seg.origin.x = p1.x;
seg.origin.y = p1.y;
If, on the other hand, you want to store a segment as 2 points, then make another class with members e.g. from and to, and adapt the computations accordingly to the substitution
v3 := p1
v4 := p2 - p1
resp. in code
x3 = seg.from.x;
y3 = seg.from.y;
x4 = seg.to.x - seg.from.x;
y4 = seg.to.y - seg.from.y;