From the Players Handbook:
Wizards Spell Book (p.114)
Copying a Spell into the Book. When you find a wizard spell
of 1st level or higher, you can add it to your spellbook if it is
of a level for which you have spell slots and if you can spare
the time to decipher and copy it.
Warlock Book of Ancient Secrets (p.110)
On your adventures, you can add other ritual spells to
your Book of Shadows. When you find such a spell, you
can add it to the book if the spell’s level is equal to or
less than half your warlock level (rounded up) and if you
can spare the time to transcribe the spell.
Ritual Caster Feat (p.169)
Choose one of the following classes: bard, cleric, druid, sorcerer,
warlock, or wizard. You must choose your spells
from that class’s spell list, and the spells you choose
must have the ritual tag.
If you come across a spell in written form, such as a
magical spell scroll or a wizard’s spellbook, you might
be able to add it to your ritual book. The spell must be
on the spell list for the class you chose, the spell’s level
can be no higher than half your level (rounded up), and
it must have the ritual tag.
Warlock Book of the Shadows (p.108)
Your patron gives you a grimoire called a Book of
Shadows. When you gain this feature, choose three
cantrips from any class’s spell list. While the book is on
your person, you can cast those cantrips at will. They
don’t count against your number of cantrips known.
Ritual Casting for Bard, Cleric, Druid (p.various)
You can cast a xxx spell as a ritual if that spell has the
ritual tag and you have the spell prepared.
Ritual Casting for Wizard
You can cast a wizard spell as a ritual if that spell has
the ritual tag and you have the spell in your spellbook.
You don’t need to have the spell prepared.
Let's deal with the last 2 first (because they're easy):
Ritual Casting has nothing to do with books at all! If you are of one of the classes that has this ability and you have a ritual spell prepared, you may cast it as a ritual which takes 10 minutes but doesn't cause you to use a spell slot.
Warlock Book of Shadows (from Pact of the Tome) is very specific that you put cantrips in them when you create the tome - these never change and can't be copied because no class other than the warlock writes cantrips down and a warlock cannot add to this book.
For the Wizard's spellbook and Warlock's Book of Shadows, I would say that what is written in the Wizard's spellbook is a Wizard spell - if it is a ritual spell then a Warlock can copy it into their Book of Shadows, subject to the constraints given. Similarly, if the Warlock has the Book of Ancient Secrets eldritch invocation, then what is in the Warlock's Book of Shadows is a Wizard (ritual) spell so a Wizard can copy it.
For the Ritual Caster Feat, if you chose Wizard you could copy from a Wizards spell book and vice-versa. If you chose anything (including Wizard), you could copy from the Warlock book if it matched your chosen class and vice-versa.
Bards, clerics and druids may cast ritual spells only from those prepared.
Warlocks, Wizards and those with the Ritual Caster feat may cast rituals only from their own book.
Results may vary, check with your DM.