A scene from Hidden Figures.

Katherine Johnson, one of the most brilliant mathematicians of the last century (and still going at age 98), gets the movie she deserves with Hidden Figures, an entertaining, enlightening and educational look at the contributions she and her cohorts made to NASA and space flight in the late 1950s and beyond.

Johnson was part of a segregated division at NASA in the 1950s, a wing of mathematicians who did the work that computers do today. The movie depicts the humiliation she and two other African-American women (Dorothy Vaughan and Mary Jackson) went through while solving equations that helped put men safely into space—and got them back home to their families.

The women had to put up with a lot of racist bullshit, and the film shows their hardships, albeit in PG fashion. There was a stretch when Johnson was making monumental calculations for the likes of Alan Shepard, yet she wasn’t allowed to use the bathrooms in her building or drink from the same coffee pot as her white counterparts.

Taraji P. Henson plays Johnson, the “smart one” who John Glenn personally demanded check the coordinates before his historical flight launched. Henson is perfection in the role, depicting Johnson as the super-awesome nerd she is. She has a scene in which she takes her fellow mathematicians at NASA to task for their racist ways, and it’s a stunner. Henson gives the film, and Johnson, the true sense of majesty they deserve.

Octavia Spencer is her usual great self as Vaughan, doing the work of a supervisor without the title; she’s also curious about that new IBM thing they just installed down the hall. Vaughan would become crucial to the implementation of computers at NASA, and became the agency’s first African-American supervisor.

As Jackson, NASA’s first female African-American aeronautical engineer, singer Janelle Monae is so good that it’s easy to forget that this is just her second movie role. (She was also excellent in 2016’s Moonlight.) Monae acts with the confidence of somebody who has been at it for decades. She is undoubtedly one of 2016’s great acting discoveries.

As a composite, fictional character named Al Harrison, Kevin Costner does some of his best acting in years. He shows America’s drive to reach space before the Russians, while realistically depicting the kind of progressive change men like him would have to make in the name of civil rights. He’s also one of very few actors who can chew gum onscreen without annoying the hell out of me.

Not only is Hidden Figures a movie you can put alongside The Right Stuff and Apollo 13 as an authentic, captivating depiction of the space race; it stands alongside 2016’s The Birth of a Nation and Loving as an important cinematic time capsule regarding the Civil Rights Movement. I suspect this movie doesn’t even scratch the surface of what Johnson, Vaughan and Jackson accomplished and endured, but it does bring their historical significance to light.

Director Theodore Melfi’s sophomore effort (after the likable St. Vincent) is a large step forward in scope and significance. He treats the subject respectfully, finding moments for humor while not letting up on the injustices showered upon the trio. His movie looks good—it’s a convincing simulation of what the inner workings of NASA must’ve looked like back in the day. Hans Zimmer contributes one of the 2016’s most rousing and satisfying scores.

Kirsten Dunst, Jim Parsons and Mahershala Ali (Monae’s co-star in Moonlight) all contribute admirably in supporting roles. Ali plays Johnson’s second husband, Col. Jim Johnson, who is still alive and living with Katherine in Hampton, Va. Katherine and Jim are proof that math power is better than broccoli!

Going into Hidden Figures, I had no knowledge of these three women and what they meant to the space race. Learning about them and, consequently, appreciating them makes this film worthwhile. The three leads and Costner make the whole thing tremendously entertaining, too.

Hidden Figures opens Friday, Jan. 6, at theaters across the valley.