I am trying to solve this where i am trying to check if a Certain Point are inside a box
A point has Xval and Y val (numeric)
A box has fields BOTTOM and TOP which are TYPE POINT
On a grid where a box is placed:
A point on the top right corner is Y Value (top), X value (right)
A point on the bottom right corner has Y value (bottom), and X value (left)
Therefore i wrote this :
create or replace type POINT as object
(xval number, yval number,
member function x return number,
member function y return number
)
create or replace type body point as
member function X return number is
begin
return xval;
end;
member function y return number is
begin
return yval;
end;
end;
I have created type point with member function X,Y with returns XVAL and YVAL above
I now need to create Type Box with member function which returns 1 or 0 (true or false)
If points(x,y) are inside a box then:
if (left <=x) and (x<=right)) and ((bottom <=y) and (y<=top))
then return 1; //contains point in box if true
else return 0; / contains point in box if false
end if;
CAN YOU HELP WITH THIS, i unsure in PL /SQL?
I started with :
create or replace type box as object
( point1 number, point 2 number,
member function ContainPB( aPoint Point) return number)