Your atlas can described in two ways : either in UV space (ranging from 0 to 1 in both coordinates) or in texel space (ranging from 0 to 1024 in width (x) and from 0 to 512 in height (y)).
To transform texel space to UV space, all you have to do is divide by texture size (width for U, and height for V).
Now supposing your first texture is on the left part of your atlas, its texel space is ranging from (0,0) to (512, 512) - it’s UV space range would be (0/1024, 0/512) to (512/1024, 512/512) ; that is to say (0,0) to (0.5, 1)
Supposing your second texture is on the right part, aligned to the bottom, its texel space is ranging from (512,0) to (1024, 256) - it’s UV space would be (512/1024, 0/512) to (1024/1024, 256/512) ; saying (0.5, 0) to (1, 0.5).
This gives you the ranges in UV space of your subtextures. As you want to transform you sources UVs (in range (0,0) - (1,1)) to these ranges, you need to scale them, to match the subtexture size, and offset them, to match the subtexture location.
The subtexture location (or offset) is the minimum value of the range described above :
- (0,0) for texture one
- (0.5, 0) for texture two
The scale factor is the (width, height) of you subtexture :
- for texture one, (0.5, 1) - (0,0) = (0.5, 1)
- for texture two, (1, 0.5) - (0.5, 0) = (0.5, 0.5)
To finally get to the point, you first vertex with UV (0.7, 0.4) would give you (0.70.4+0, 0.41+0) for texture one.
Your second vertex with UV (0.4, 0.8) would give you (0.40.5+0.5, 0.80.5+0) for texture two.
Hope you get the point, I tried to be as explicit as I could