Typically, as KC said, the hinge is located near the back bulkhead or upper galley cabinet. I would start at the front first, figure out your mattress length, location, toe space for turning over at night, and go from there. If there's a shelf or cabinet above the toe space for the mattress, the hinge would be on the back side of this area. You don't want it inside the cabin, so it needs to be in the galley area. I wouldn't make any decision about the hinge until I did a layout & mock-up of the length first. Then you have better information to make the decision with and can decide where it will be.
The other end of this decision is the galley. Once the bed is worked out, the galley layout needs to be done with cooler, sink, stove, etc. located in the remaining space. Like the front, start with the biggest thing you will have in there (cooler?). Decide where it needs to go and then decide how the rest works out. Only then you can make a good decision about the hinge location.
Mine is like KC's in shape (it's a 5' X 9'). Here's a picture showing a mock-up with the side in place on the frame. There will be a full bulkhead in mine, which runs from the floor to the ceiling. The hinge is just behind the bulkhead location. At the back you can see the galley wall, counter, & upper cabinets (the kitchen's upper in back & the storage cabinet above the toe space for the mattress). On mine the bulkhead will be in a continuous slot running into the ceiling, walls & floor. This will stiffen up the rear of the box. It's only 1/4" plywood, but once it's glued in place, fastened & has cabinets attached, it will be plenty strong for a box this size. The hinge point will be just behind the bulkhead, so it will be fastened in place and reinforced by the bulkhead, cabinets, ceiling, spars & walls.
I would encourage you to stop at this point and not pick an arbitrary number, but one based on the actual layout. It might end up at 22", but it might not.
