CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Mesh Generation & Pre-Processing Software > ANSA

How to find normal to plane using script?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2017, 08:44
Default How to find normal to plane using script?
  #1
New Member
 
Renuka
Join Date: Aug 2017
Posts: 15
Rep Power: 8
Renu123 is on a distinguished road
If I have a plane, is there a quick way to get the normal vector? (just a simple plane, no surface, no edges or points).
def main():
# creating a plane
x1,y1,z1=500,90,200
x2,y2,z2=50,100,200
x3,y3,z3=600,30,45
plane_1=base.CreateWplane3Points(x1,y1,z1,x2,y2,z2 ,x3,y3,z3)
Renu123 is offline   Reply With Quote

Old   September 16, 2017, 13:28
Cool Normal plane to three points
  #2
New Member
 
Join Date: Sep 2017
Posts: 5
Rep Power: 8
maddoxx is on a distinguished road
Hi,
I am new to this forum. And glad to help you on this one.
Function takes 3 point ordinates [x1,y1,z1],[x2,y2,z2],[x3,y3,z3].
And returns unit vector for the plane formed by the 3 points

Code:
import ansa

def normalVector2Plane(pnt1,pnt2,pnt3):# 3 points 
	def vector(point1,point2):
		delx=point2[0]-point1[0]
		dely=point2[1]-point1[1]
		delz=point2[2]-point1[2]
		magnitude=(delx*delx+dely*dely+delz*delz)**0.5 # Distance from Distance Formula
		if(magnitude!=0):
			x=delx/magnitude
			y=dely/magnitude
			z=delz/magnitude
			return [x, y, z] # Unit Vecor
		else:
			return 0
	a = vector(pnt1, pnt2)
	b = vector(pnt1, pnt3)
	return ansa.calc.CrossProduct(a, b) # Cross Product of 2 Vectors
maddoxx is offline   Reply With Quote

Old   September 16, 2017, 15:27
Default
  #3
New Member
 
Renuka
Join Date: Aug 2017
Posts: 15
Rep Power: 8
Renu123 is on a distinguished road
Quote:
Originally Posted by maddoxx View Post
Hi,
I am new to this forum. And glad to help you on this one.
Function takes 3 point ordinates [x1,y1,z1],[x2,y2,z2],[x3,y3,z3].
And returns unit vector for the plane formed by the 3 points

Code:
import ansa

def normalVector2Plane(pnt1,pnt2,pnt3):# 3 points 
	def vector(point1,point2):
		delx=point2[0]-point1[0]
		dely=point2[1]-point1[1]
		delz=point2[2]-point1[2]
		magnitude=(delx*delx+dely*dely+delz*delz)**0.5 # Distance from Distance Formula
		if(magnitude!=0):
			x=delx/magnitude
			y=dely/magnitude
			z=delz/magnitude
			return [x, y, z] # Unit Vecor
		else:
			return 0
	a = vector(pnt1, pnt2)
	b = vector(pnt1, pnt3)
	return ansa.calc.CrossProduct(a, b) # Cross Product of 2 Vectors
Thank you I will try it.
Renu123 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a code parallel? Bruno Machado Fluent UDF and Scheme Programming 15 May 27, 2016 10:18
[foam-extend.org] Installing foam-extend 3.1 on Ubuntu 14.04 stephie OpenFOAM Installation 16 April 23, 2015 17:18
CFX problem in ubuntu (linux) Vigneshramaero CFX 0 July 13, 2012 11:22
Normal vector, slope and aspect angle g_niro Main CFD Forum 0 February 2, 2011 18:24
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30


All times are GMT -4. The time now is 07:44.