Ternary algebras associated with irreducible tensor representations of SO(3) and quark model