display surface normal using quiver3 (2024)

16 views (last 30 days)

Show older comments

MK on 5 Mar 2017

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3

Commented: MK on 12 Mar 2017

Accepted Answer: Rahul Kalampattel

Open in MATLAB Online

I have an MxN matrix Z after some processing, and wanted to retrieve the surface normals (as well as view it on a plot)

I've tried surfnorm(Z), but since it had looked pretty messy I thought of simply using quiver3, with the surface normals from the return value of surfnorm. Since the documentation states that quiver3(x,y,z,u,v,n) usage is such that the (u, v, n) vectors would be at location(x,y,z), I tried the following:

% I checked that surf(Z) and surf(X, Y, Z) gave the same plot

X = zeros(M, N);

Y = zeros(M, N);

for k = 1:M

X(k, :) = k;

end

for k = 1:N

Y(:, k) = k;

end

[U, V, W] = surfnorm(Z);

quiver3(X, Y, Z, U, V, W);

but I simply got a "cylindrical" vector plot (seemingly as if the origin of the vectors are the same (center of cylinder)). I tried with different Z matrices but the quiver3 plot was always similar looking.

Am I understanding any of the functions wrong? Would really appreciate some help.

surf result:

display surface normal using quiver3 (2)

surfnorm result:

display surface normal using quiver3 (3)

quiver3 result:

display surface normal using quiver3 (4)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Rahul Kalampattel on 6 Mar 2017

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#answer_257401

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#answer_257401

Edited: Rahul Kalampattel on 6 Mar 2017

Open in MATLAB Online

1. Use

[U,V,W] = surfnorm(X,Y,Z);

instead of

[U,V,W] = surfnorm(Z);

This will make sure that the quiver3 vectors are mapped to the right coordinates.

2. If you look at the last plot, the X/Y axes scales are 14 orders of magnitude larger than in your surf and surfnorm plots. The vectors from quiver3 are too long, which gives the illusion of a cylindrical plot. This might be fixed after step 1, but if not you can rescale them using

quiver3(X,Y,Z,U,V,W,0.5); % Half scale

3. If the two plots still aren't matching, this answer might help: https://au.mathworks.com/matlabcentral/answers/100252-why-do-the-surface-norms-calculated-by-surfnorm-and-quiver3-not-coincide-in-matlab-6-5-r13?s_tid=answers_rc1-1_p1_MLT

4 Comments

Show 2 older commentsHide 2 older comments

MK on 7 Mar 2017

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434701

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434701

Hey, thanks for your answer. The issue here really was the scale (both surfnorm(Z) and surfnorm(X,Y,Z) returned the same values for the matrices U,V,W).

Did not notice until you pointed it out, but as the scale was many magnitudes larger, I set the scale in quiver3(x,y,z,u,v,w, scale) the same orders of magnitude smaller. Tried on a different image and its actually showing a proper figure now. I'll still need to figure about changing the color with the U,V,W direction to make it clearer though. Thanks.

surf result:

display surface normal using quiver3 (7)

surfnorm result:

display surface normal using quiver3 (8)

quiver3 result:

display surface normal using quiver3 (9)

On another note, would you happen to know how the scaling is done in the quiver3 plot ? I had actually assumed that the size of the vector would be given by the values in my U, V and W matrices.. Also did not see any mention about the 'default' vector scale in the quiver3 documentation..

Rahul Kalampattel on 7 Mar 2017

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434710

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434710

U,V and W do specify the lengths of each vector, but by default the result is autoscaled.

From the documentation, "The quiver3 function automatically scales the vectors to prevent overlapping based on the distance between them".

You can turn this off by setting the scale parameter to 0, but it might be a bit messy.

Rahul Kalampattel on 7 Mar 2017

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434715

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_434715

Open in MATLAB Online

Also I'm not sure exactly what you want as far as having different coloured vectors in different directions goes, but this is one way to do it.

hold on

% Vectors with positive U are blue, the rest are red

quiver3(X,Y,Z,(U>=0).*U,(U>=0).*V,(U>=0).*W)

quiver3(X,Y,Z,(U<0).*U,(U<0).*V,(U<0).*W, 'color', 'r')

display surface normal using quiver3 (12)

MK on 12 Mar 2017

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_436317

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/328149-display-surface-normal-using-quiver3#comment_436317

Yes I saw the documentation as well. But since my vectors had a range of 0-1, I thought they would not have been upscaled, so I did not notice the magnification.

Regarding the colour, I was thinking more that the corresponding (u,v,w) vectors would give the (r,g,b) colours, since the range of (u,v,w) was 0-1. For now though, I have actually done away with the colour display since the vectors (after downscaling) are really small, and direction less clear. I'm actually now just working with the values instead.

By the way, thanks for the help!

Sign in to comment.

More Answers (0)

Sign in to answer this question.

See Also

Categories

MATLABGraphicsFormatting and Annotation3-D Scene ControlLighting, Transparency, and Shading

Find more on Lighting, Transparency, and Shading in Help Center and File Exchange

Tags

  • quiver3
  • surfnorm

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


display surface normal using quiver3 (14)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

display surface normal using quiver3 (2024)
Top Articles
Anatomy Drawing Lessons
Anatomy Drawing Lessons
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
R/Skinwalker
Rugged Gentleman Barber Shop Martinsburg Wv
Jennifer Lenzini Leaving Ktiv
Justified - Streams, Episodenguide und News zur Serie
Epay. Medstarhealth.org
Olde Kegg Bar & Grill Portage Menu
Cubilabras
Half Inning In Which The Home Team Bats Crossword
Amazing Lash Bay Colony
Juego Friv Poki
Dirt Devil Ud70181 Parts Diagram
Truist Bank Open Saturday
Water Leaks in Your Car When It Rains? Common Causes & Fixes
What’s Closing at Disney World? A Complete Guide
New from Simply So Good - Cherry Apricot Slab Pie
Drys Pharmacy
Ohio State Football Wiki
Find Words Containing Specific Letters | WordFinder®
FirstLight Power to Acquire Leading Canadian Renewable Operator and Developer Hydromega Services Inc. - FirstLight
Webmail.unt.edu
2024-25 ITH Season Preview: USC Trojans
Metro By T Mobile Sign In
Restored Republic December 1 2022
12 30 Pacific Time
Jami Lafay Gofundme
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 5577

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.