In short "no, it's not legal".
The libraries possession of a physical copy of the book does not confer rights on you to get an electronic copy. (For a few reasons, one is that there is no control to prevent the book being lent out to someone else while you use it electronically - i.e., 2 copies)
[ There are, occasionally, exceptions to what I've written - for example if the book has a license which allows it to be copied - that would not apply to most current books - particularly current text books. ]
Regarding the word "piracy", taken literally, that is something that generally occurs on the high seas. But, "piracy" has long been used to mean copyright infringement. In Goldstein v. California 412 U.S. 546 (1973), the Supreme Court recognized the unauthorized duplication of recordings has commonly been called piracy. The American Heritage Dictionary has a definition that means infringement.