I'm assuming Metric is set as Unit System and Meters as Length in Scene Properties tab. If you're using any other unit, including those from Imperial system, simply convert the values calculated below as meters to the unit of your choice [Blender also operates on meters and converts them to other units if necessary ].
Using Orthographic camera, Blender takes the longer of the output dimensions and treats it as
unit_scale * orthographic_scale meters. So increasing either Unit Scale or Orthographic Scale increases the area visible by the orthographic camera. Since Blender automatically scales objects when you change the Unit Scale, you can see the change by observing the grid in Top Orthographic View:
So for 200x100 dimensions, 1.0 unit scale, 1.0 orthographic scale, 200 pixels represent
1.0*1.0 = 1 meter and 1 pixel represents
1/200 = 0.005 meters or half a centimeter. For 100x500 dimensions, 2.0 unit scale, 2.0 orthographic scale, 500 pixels represent
2.0*2.0 = 4 meters and 1 pixel represents
4/500 = 0.008 m or 8 mm. Assuming square pixels here.
pixel_width = pixel_height = unit_scale * orthographic_scale / longer_output_dimension
You have output dimensions and target pixel dimensions (distance between centers of pixels), but you want to calculate the
orthographic_scale, so you can multiply both sides of the equation by
longer_output_dimension and then divide both sides by
unit_scale to move them to the other side:
pixel_width * longer_output_dimension / unit_scale = orthographic_scale.
For 512x512 dimensions, 0.4 m pixel width and 1.0 unit scale:
orthographic_scale = 0.4 * 512 / 1.0 = 204.8.
Step by step example
Let's say we want to duplicate (yes, not delete) starting cube a few times and make sure cubes are aligned to pixels. Therefore, pixel dimensions should equal cube dimensions - 2 m, and axis-aligned distances between cubes have to be multiples of 2 m.
- Press Numpad 7 for Top Orthographic View.
- Select the cube. Press SHIFT + D to duplicate it, hold CTRL and position it. Repeat a few times.
- Select the original (center) cube, press / to center view on it, then CTRL + ALT + Numpad 0 to set the camera to active view and / again to exit Local View.
- Since each cube should correspond to one pixel, in this example we can fit everything in 5x5 dimensions, so let's set such dimensions in Output Properties tab
- Press Numpad 0 for camera view, select the camera and in the Object Data Properties tab change its type to Orthographic. Set the Orthographic Scale to
2 * 5 [2 m cube dimension times longer output dimension] - Blender will accept a simple expression like that.
As you can see, cubes are aligned to pixels.