Generate position by function