MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Jun 3rd, 2002, 08:41 PM   #1
Serious
 
Join Date: May 2002
Posts: 18
Default

I have a table of x, y and z coordinates and was wondering if there is a way to have Excel create a 3-D shape from these vertices values. I would greatly appreciate anyone's help.

Thanks,
Serious
Serious is offline   Reply With Quote
Old Jun 4th, 2002, 05:51 AM   #2
Vas
 
Join Date: May 2002
Location: Gothenburg, Sweden
Posts: 74
Default

I know how to convert these yourself, but I don't think Excel will do that for you.
If you're interested, post a reply.
__________________
/Niklas Jansson
Vas is offline   Reply With Quote
Old Jun 4th, 2002, 01:53 PM   #3
Serious
 
Join Date: May 2002
Posts: 18
Default

Yes, I am interested. I would appreciate your ideas.
Serious is offline   Reply With Quote
Old Jun 4th, 2002, 05:42 PM   #4
Serious
 
Join Date: May 2002
Posts: 18
Default

What program would you use?
Serious is offline   Reply With Quote
Old Jun 5th, 2002, 06:03 AM   #5
Vas
 
Join Date: May 2002
Location: Gothenburg, Sweden
Posts: 74
Default

You could use any program you like. If you really need to do 3D, you should probably use AutoCAD or something like that, all I can tell you is some conversions and such.

I must tell you, though - it is complicated mathematic behind.

You need to convert "World Data" to "Camera Data".
Do you want to be able to rotate and move the camera?
Do you want to move/rotate the object?
Do you want surfaces or just wireframe?

__________________
/Niklas Jansson
Vas is offline   Reply With Quote
Old Jun 5th, 2002, 08:07 AM   #6
Vas
 
Join Date: May 2002
Location: Gothenburg, Sweden
Posts: 74
Default

That sounded weird. If you want to make 3D-objects yourself you could use any program, VB, some C++ compiler or even Excel.

If you really need these 3D-objects to be perfect you should consider a program designed for 3D, Like 3DsMAX or Bryce (?) or some CAD-program (I know AutoCAD has 3D-possibilties).

If you want to make it in excel (which is a rather funny idea, and I'd really like to see the result if you're going to do it), you'll need some mathematical transformations from 3D-space to 2D.

You also need to make a number of decisions regarding how complex it should be.

For a standard wireframe method there shouldn't be any particularly hard task, but just the step from wireframe to "Hidden line removal" (you only see the part of the lines actually visible) is a rather big. It could actually be easier with a surface rendering.


__________________
/Niklas Jansson
Vas is offline   Reply With Quote
Old Jun 5th, 2002, 01:44 PM   #7
Serious
 
Join Date: May 2002
Posts: 18
Default

Hey Vas,
Okay. I dont have access to AutoCad right now. I do have access to a program called MathCAD. In this program, I can create 3D surfaces based on equations--but I can't figure out how to create a shape based on its vertices.

I just want a basic 3D shape that verifies that my vertice values are correct. I don't need to rotate the camera or the shape although MathCAD has these abilities. And wireframe would be fine.

Thanks for your help,
Serious
Serious is offline   Reply With Quote
Old Jun 5th, 2002, 02:24 PM   #8
PHMayfield
 
Join Date: May 2002
Location: Phoenix, AZ, USA
Posts: 29
Default

This might be a dirty way to get an idea of what your data looks like. Try doing three scatter plots with (x,y), (x,z), and (y,z) as your data sets. you will get three "views" of your data. I know this is completely non-elegant, but it also requires almost no work.
PHMayfield is offline   Reply With Quote
Old Jun 5th, 2002, 03:52 PM   #9
Serious
 
Join Date: May 2002
Posts: 18
Default

Hey PH,

Thanks for the suggestion. I tried that and it does a decent job of portraying the shape. I still want to try the 3D approach so that other users can get a good picture of what the shape will look like right away from one graph but now I do have something to fall back on in case the 3D approach is too difficult.

Thanks
Serious
Serious is offline   Reply With Quote
Old Jun 6th, 2002, 05:48 AM   #10
Vas
 
Join Date: May 2002
Location: Gothenburg, Sweden
Posts: 74
Default

Ok, good. Then there should be no problem.

First: if the object is centered around (0,0,0) you need a camera (and it's a good idea anyway).

Code:
Public Type Point3D
    X As Double
    Y As Double
    Z As Double
End Type

Private CameraPoint As Point3D
No need for any rotations.
To convert the "World" point to Camera point we'll need a Function for that. (Very easy - no rotations!)

Code:
Public Function WorldToCamera (Point As Point3D) As Point3D
    With WorldToCamera
        .X = Point.X - CameraPoint.X
        .Y = Point.Y - CameraPoint.Y
        .Z = Point.Z - CameraPoint.Z
    End With
End Function
Then we need a Function to convert from the Camera point to Screen point:
Code:
Public Type Point2D
    X As Double
    Y As Double
End Type

Const D As Double=1 'Tweak this if you want to change perspective

Public Function CameraToScreen(Point as Point3D) As Point2D
    With CameraToScreen
        If Point.Z = 0 Then 'The point is exactly in your eyes
            .X = -10000
            .Y = -10000
        Else
            .X = d * Point.X / Point.Z
            .Y = d * Point.Y / Point.Z
        End If
    End With
End Function
Now this Screen point need to be used somehow. (0,0) should be the center of the screen.

If you need further help, reply again.
__________________
/Niklas Jansson
Vas is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 02:29 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.