Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- get_random_obj_cord_wrt_mirror(O,M,Tx,Ty,Bx,By, ObjectPlacement) :-
- mirror_type(M, MirrorType),
- MirrorType \== plane,
- %% TODO check that new object does not overlap with existing object if it exists
- (retract(eqn_surface(M,Type,G,F,C,Pole_x, Pole_y)) -> assert(eqn_surface(M,Type,G,F,C,Pole_x, Pole_y)); read(_),false),
- (retract(surface(M,Surface_type,Surface_shape,Focal_length)) -> assert(surface(M,Surface_type,Surface_shape,Focal_length)); read(_),false),
- Centre_x is -G,
- Centre_y is -F,
- Radius is sqrt(G*G + F*F - C),
- T1 is round(Centre_x + (Radius/sqrt(2))),
- T2 is round(Centre_x - (Radius/sqrt(2))),
- T3 is round(Centre_y + (Radius/sqrt(2))),
- T4 is round(Centre_y - (Radius/sqrt(2))),
- nl,write(T1),
- nl,
- write(T2),
- nl,
- write(T3),
- nl,
- write(T4),nl,
- %% front means object is on the left
- %% back means object is on the right
- (Surface_type == mirror ->
- (Surface_shape == concave ->
- (
- ObjectPlacement == front ->
- (
- Centre_x > Pole_x ->
- random_between(round(Pole_x - 2 * Radius), round(Pole_x - 1), Tx),
- random_between(T4, T3, Ty);
- random_between(T2, T1, Tx),
- random_between(T4, T3, Ty)
- );
- (
- Centre_x > Pole_x ->
- random_between(T2, T1, Tx),
- random_between(T4, T3, Ty);
- random_between(round(Pole_x + 1), round(Pole_x + 2 * Radius), Tx),
- random_between(T4, T3, Ty)
- )
- );
- %% Convex Mirror
- (
- ObjectPlacement == front ->
- (
- Centre_x > Pole_x ->
- random_between(round(Pole_x - 2 * Radius), round(Pole_x - 1), Tx),
- random_between(T4, T3, Ty);
- random_between(round(Pole_x + 1), round(Pole_x + 2 * Radius), Tx),
- random_between(T4, T3, Ty)
- );
- random_between(T2, T1, Tx),
- random_between(T4, T3, Ty)
- )
- );
- %% TODO We have only taken one side of lens, take two sides
- random_between(T2, T1, Tx),
- random_between(T4, T3, Ty)
- ),
- nl,write('error here'),nl,read(_),
- get_bottom_cord_from_top_cords(T1,T2,T3,T4, Tx, Ty, Bx, By).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement