Difference between revisions of "Bezier Class"

From Derivative
Jump to navigation Jump to search
(Created page with "'''BUILD NOTE: Only available in experimental builds 2017.30000+'''<br> <!--PYH Bezier--> The Bezier class holds a single Bezier primitive. It is an instance of a Prim Cla...")
 
Line 1: Line 1:
'''BUILD NOTE: Only available in experimental builds 2017.30000+'''<br>
+
{{TDClassSummary|summary=A Bezier describes an instance of a single geometry Bezier primitive (containing a set of connected Bezier curves).  It is an instance of a Prim Class.
 
 
<!--PYH Bezier-->
 
The Bezier class holds a single Bezier primitive.  It is an instance of a [[Prim Class]].
 
 
It can be created from either a [[modelSOP Class|Model SOP]] or [[scriptSOP Class|Script SOP]].
 
It can be created from either a [[modelSOP Class|Model SOP]] or [[scriptSOP Class|Script SOP]].
 
Each curve is described by a set of segments, where each segment is a list of vertices. The first and last vertex of each segment is an anchor position, while its neighboring vertices describe tangent handles.
 
Each curve is described by a set of segments, where each segment is a list of vertices. The first and last vertex of each segment is an anchor position, while its neighboring vertices describe tangent handles.
  
 
The members and methods below allow modification of the Bezier in a modelling context, however the Bezier can also be modified by direction manipulation of its [[Vertex Class|vertices]].  See [[Prim Class]] for more details.
 
The members and methods below allow modification of the Bezier in a modelling context, however the Bezier can also be modified by direction manipulation of its [[Vertex Class|vertices]].  See [[Prim Class]] for more details.
 
+
}}
<!--PYHEND-->
+
<section begin=HELPBODY />
 
+
{{ClassMemberSection|empty=
<section begin=MEMBERS />
+
|Sectionsummary=
== Members ==
+
|items=
 
+
{|style=cellpadding="0" cellspacing="5"
+
{{ClassMember
 
+
    |class=Bezier
|valign="top"|<code>'''order'''</code>
+
    |name=anchors
<!--PYHGET order -->
+
    |type=
||The order of the curve. The order is one more than it's degree.
+
    |set=0
<!--PYHEND-->
+
    |text=Returns the list of anchor vertices.
|-
+
}}
 
+
{{ClassMember
|valign="top"|<code>'''closed'''</code>
+
    |class=Bezier
<!--PYHGETSET closed-->
+
    |name=basis
||Control whether the curve is open (unconnected curve) or closed (solid closed face).
+
    |type=
<!--PYHEND-->
+
    |set=0
|-
+
    |text=Return the bezier basis as a list of float values.
 
+
}}
|valign="top"|<code>'''basis'''</code>
+
{{ClassMember
<!--PYHGET basis-->
+
    |class=Bezier
||The basis as a list of float values.
+
    |name=closed
<!--PYHEND-->
+
    |type=
|-
+
    |set=0
 
+
    |text=Controls whether the curve is closed or open.
|valign="top"|<code>'''anchors'''</code>
+
}}
<!--PYHGET anchors-->
+
{{ClassMember
||The list of anchor [[Vertex Class|vertices]].
+
    |class=Bezier
<!--PYHEND-->
+
    |name=order
|-
+
    |type=
 
+
    |set=0
|valign="top"|<code>'''tangents'''</code>
+
    |text=Return the bezier order. The order is one more than the degree.
<!--PYHGET tangents-->
+
}}
||The tangents as a list of [[Vertex Class|vertex]] pairs.
+
{{ClassMember
<!--PYHEND-->
+
    |class=Bezier
|-
+
    |name=segments
 
+
    |type=
|valign="top"|<code>'''segments'''</code>
+
    |set=0
<!--PYHGET segments-->
+
    |text=Returns a list of segments, where each segment is a list of vertices.
||The list of segments, where each segment is a list of [[Vertex Class|vertices]].
+
}}
<!--PYHEND-->
+
{{ClassMember
 
+
    |class=Bezier
|}
+
    |name=tangents
 
+
    |type=
<section end=MEMBERS /><section begin=METHODS />
+
    |set=0
 
+
    |text=Returns the tangents as a list of vertex pairs.
== Methods ==
+
}}}}
 
+
{{ClassMethodSection|empty=
<!--PYHMK appendAnchor-->
+
|Sectionsummary=
'''<code>appendAnchor(targetPosition, ''preserveShape=True'')</code> &rarr; <code>Vertex</code>'''
+
|items=
:Appends a set of vertices, creating a new segment on the curve, ending with the targetPosition.
+
:Returns final anchor vertex.
+
{{ClassMethod
:* <code>targetPosition</code> - The final target [[Position Class|position]]. The position argument can be any 3-valued tuple.
+
    |class=Bezier
:* <code>preserveShape</code> - '''(Keyword, Optional)''' Specifies whether or not the new tangent will align with the previous segment.
+
    |name=insertAnchor
<!--PYHEND-->
+
    |call=insertAnchor(u)
 
+
    |returns=
<!--PYHMK updateAnchor-->
+
    |text=:
'''<code>updateAnchor(anchorIndex, targetPosition, ''tangents=True'')</code> &rarr; <code>Position</code>'''
+
inserts anchor at given position (u from 0..1) and returns anchor vertex.
:Modify the anchor vertex to the new position.
+
}}
:Returns resulting position.
+
{{ClassMethod
:* <code>anchorIndex</code> - The index of the anchor vertex to update.
+
    |class=Bezier
:* <code>targetPosition</code> - The final target [[Position Class|position]].  The position argument can be any 3-valued tuple.
+
    |name=updateAnchor
:* <code>tangents</code> - '''(Keyword, Optional)''' If <code>True</code>, modify neighboring tangent vertices as well.
+
    |call=updateAnchor(anchorIndex, targetPosition, tangents=True)
<!--PYHEND-->
+
    |returns=
 
+
    |text=: -> tdu.Position
<!--PYHMK updateTangent-->
+
Modify the anchor vertex to the new position.  If tangents is True, modify neighbouring tangent vertices as well.
'''<code>updateTangent(tangentIndex, targetPosition, ''rotate=True'', ''scale=True'', ''rotateLock=True'', ''scaleLock=True'')</code> &rarr; <code>Position</code>'''
+
Returns resulting position.
:Modify the vertex vertex to the new position, constraining either rotation or scale.
+
}}
:Returns resulting position.
+
{{ClassMethod
:* <code>tangentIndex</code> - The index of the tangent vertex to update.
+
    |class=Bezier
:* <code>targetPosition</code> - The final target [[Position Class|position]].  The position argument can be any 3-valued tuple.
+
    |name=appendAnchor
:* <code>rotate</code> - '''(Keyword, Optional)''' If <code>True</code> modify the tangent angle.
+
    |call=appendAnchor(targetPosition, preserveShape=True)
:* <code>scale</code> - '''(Keyword, Optional)''' If <code>True</code> modify the tangent length.
+
    |returns=
:* <code>rotateLock</code> - '''(Keyword, Optional)''' If <code>True</code> modify the matching tangent angle.
+
    |text=: -> Vertex
:* <code>scaleLock</code> - '''(Keyword, Optional)''' If <code>True</code> modify the matching tangent length.
+
preserveShape - (Keyword, Optional) Specifies whether the new tangent will align with the previous segment or not.
<!--PYHEND-->
+
Appends a set of vertices, creating a new segment on the curve, ending with the targetPosition.
 
+
Returns final anchor vertex.
<!--PYHMV deleteAnchor-->
+
}}
'''<code>deleteAnchor(anchorIndex)</code>'''
+
{{ClassMethod
:Deletes the anchor and its neighboring tangents.
+
    |class=Bezier
:* <code>anchorIndex</code> - The index of the anchor vertex to delete.
+
    |name=updateTangent
<!--PYHEND-->
+
    |call=updateTangent(tangentIndex, targetPosition, rotate=True, scale=True, rotateLock=True, scaleLock=True)
 
+
    |returns=
<!--PYHMK insertAnchor-->
+
    |text=: -> tdu.Position
'''<code>insertAnchor(u)</code> &rarr; <code>Vertex</code>'''
+
Modify the vertex vertex to the new position, constraining either rotation or scale.  Locked controls matching tangent.
:Inserts an anchor at the given position u.
+
Returns resulting position.
:Returns resulting anchor vertex.
+
}}
:* <code>u</code> - The insertion point along the curve (from 0 to 1).
+
{{ClassMethod
<!--PYHEND-->
+
    |class=Bezier
 
+
    |name=deleteAnchor
<section end=METHODS />
+
    |call=deleteAnchor(anchorIndex)
[[Category:Python Reference]]
+
    |returns=
 +
    |text=:
 +
Deletes the anchor and its neighbouring tangents.
 +
}}}}
 +
<section end=HELPBODY />
 +
{{History}}
 +
{{#invoke:Category|list|Python Reference}}

Revision as of 17:02, 6 March 2018

A Bezier describes an instance of a single geometry Bezier primitive (containing a set of connected Bezier curves). It is an instance of a Prim Class. It can be created from either a Model SOP or Script SOP. Each curve is described by a set of segments, where each segment is a list of vertices. The first and last vertex of each segment is an anchor position, while its neighboring vertices describe tangent handles.

The members and methods below allow modification of the Bezier in a modelling context, however the Bezier can also be modified by direction manipulation of its vertices. See Prim Class for more details.


Members[edit]

anchors(Read Only):

Returns the list of anchor vertices.

basis(Read Only):

Return the bezier basis as a list of float values.

closed(Read Only):

Controls whether the curve is closed or open.

order(Read Only):

Return the bezier order. The order is one more than the degree.

segments(Read Only):

Returns a list of segments, where each segment is a list of vertices.

tangents(Read Only):

Returns the tangents as a list of vertex pairs.

Methods[edit]

insertAnchor(u):

: inserts anchor at given position (u from 0..1) and returns anchor vertex.

updateAnchor(anchorIndex, targetPosition, tangents=True):

: -> tdu.Position

Modify the anchor vertex to the new position. If tangents is True, modify neighbouring tangent vertices as well.

Returns resulting position.

appendAnchor(targetPosition, preserveShape=True):

: -> Vertex

preserveShape - (Keyword, Optional) Specifies whether the new tangent will align with the previous segment or not. Appends a set of vertices, creating a new segment on the curve, ending with the targetPosition.

Returns final anchor vertex.

updateTangent(tangentIndex, targetPosition, rotate=True, scale=True, rotateLock=True, scaleLock=True):

: -> tdu.Position

Modify the vertex vertex to the new position, constraining either rotation or scale. Locked controls matching tangent.

Returns resulting position.

deleteAnchor(anchorIndex):

: Deletes the anchor and its neighbouring tangents.

TouchDesigner Build: