Let V, W be real algebraic varieties (that is, up to isomorphism, real algebraic sets), and X subset of V some subset. A map from X into W is said to be regular if it can be extended to a regular map defined on some Zariski locally closed subvariety of V that contains X. Furthermore, a continuous map f : X -> W is said to be piecewise-regular if there exists a stratification S of V such that for every stratum S is an element of S the restriction of f to each connected component of X boolean AND S is a regular map. By a stratification of V we mean a finite collection of pairwise disjoint Zariski locally closed subvarieties whose union is equal to V. Assuming that the subset X of V is compact, we prove that every continuous map from X into a Grassmann variety or a unit sphere can be approximated by piecewise-regular maps. As an application, we obtain a variant of the algebraization theorem for topological vector bundles. If the variety V is compact and nonsingular, we prove that each continuous map from V into a unit sphere is homotopic to a piecewise-regular map of class C-k, where k is an arbitrary nonnegative integer.